这个怎么样?
http://dojo.telerik.com/@Stephen/aNije
我删除了K-重新绑定属性,而不是线了您的setCarsGrid内的数据源()方法:
$scope.setCarsGrid = function() {
var row = this.brandGrid.select();
var brand = this.brandGrid.dataItem(row);
var brandObj=brand.toJSON();
var dataSource = new kendo.data.DataSource({
data: brand.cars,
schema:{
model:{
fields:{
id:{editable:false},
model:{editable:false},
color:{type:"string"}
}
},
parse: function(response) {
$.each(response, function(idx, elem) {
elem.id = elem.id+10;
//if you put a break point here, every time you try to edit 'color' field.. will be stop because datasourse is iterated again
console.log("Grid has been reloaded and the editable field 'color' can be edited :'(the id property has been added +10")
});
return response;
}
}
});
// This first time this is called, the carsGrid has not been initialized, so it doesn't exist.
// But subsequent times, we just need to set the new datasource.
if (this.carsGrid) {
this.carsGrid.setDataSource(dataSource);
}
$scope.carsGridOptions = {
dataSource: dataSource,
selectable:true,
editable: true,
columns: [{
field: "id",
},{
field: "model",
},{
field: "color",
}]
};
}
从本质上讲,我只是从设置分离网格初始化网格的DATASOURCE。 第一次通过设置网格选项并设置数据源,然后设置数据源,然后将网格设置为新的数据源。
这就避免了K-重新绑定的行为......我相信这是记录:因为这些部件是在他们的数据,例如每次改变重新http://docs.telerik.com/kendo-ui/AngularJS/introduction#widget-update-upon-option-changes
这种方法并不适用于数据绑定控件,分页后的网格。
请注意,我并不真正知道角度,所以可能有更好的方法来组织此代码,但它的工作原理。
您至少需要提供您的网格定义。更好的是,提供一个指向Kendo Dojo示例的链接,展示该问题。 –
谢谢..我已经做到了....这里是链接http://dojo.telerik.com/uYemI/2 –
我真的不知道如何解决它,但它是k-rebind =“ carsGridOptions“导致它...当editCell触发时,此属性导致k-rebind启动,因此setGridOptions触发重新绑定整个数据源(并重置网格)。您需要找到一种方法,只需将新数据推入网格,而不使用k-rebind(由于某种原因而在编辑时触发)。所以基本上,每个editCell都会导致网格重新初始化它的dataSource(通过k-rebind映射),从而导致重新读取。我们不需要那样做;;) –