我知道kendo数据源中发生了什么事件,但我想知道是否有人列出了事件触发的顺序。我试图在read()和refresh()之后重新过滤网格,但似乎无法使代码正常工作。它通过更改事件保存得很好,但我不知道在哪里实际尝试将过滤器插回到网格中,因此它将像保存之前一样进行过滤
dataSource: {
type: "json",
serverSorting: false,
batch: true,
pageSize: 50,
change: function(e) {
dataSource = $("#grid").data("kendoGrid").dataSource;
saveFilters = dataSource.filter();
sessionStorage.setItem('theGridFilters', JSON.stringify(saveFilters));
console.log("save: " + JSON.stringify(saveFilters) );
},
transport: {
read: {
url: "./grid_projectselections.php?delob=" + escape(lob),
dataType: "json",
cache: false,
complete: function () {
}
},
update: {
url: "./update_projectselections.php?delob=" + escape(lob),
dataType: "json",
complete: function () {
$("#grid").data("kendoGrid").dataSource.read();
$("#grid").data("kendoGrid").refresh();
}
},
parameterMap: function(options, operation) {
if (operation !== "read" && options.models) {
return {models: kendo.stringify(options.models)};
}
}
},
requestEnd: function(e) {
if (e.type != undefined ) {
if ( e.type === 'read' ) {
hidesavingpanel();
}
}
},
schema: {
data: "data",
total: "total",
model: {
id: "RowID",
fields: {
RowID: {editable: false},
ProjectID: {editable: false},
ProjectName: {editable: true},
HostCount: {editable: false},
HR_LEVEL_5: {editable: false},
HR_LEVEL_6: {editable: false},
HR_LEVEL_7: {editable: false},
HR_LEVEL_8: {editable: false},
HR_LEVEL_9: {editable: false},
OrgDescr: {editable: false},
GroupDescr: {editable: false},
RegionDescr: {editable: false},
SectionDescr: {editable: false}
}
}
},
},
saveChanges: function(e) {
var g = $('#grid').data('kendoGrid');
var data = g.dataSource.view();
var isdirty = false;
$.each(data, function (i, item) {
if (item.dirty) {
isdirty = true;
}
});
if ( isdirty === false ) {
return true;
}
showsavingpanel();
},
答案 0 :(得分:3)
使用远程操作时的顺序如下:
dataSource.requestStart
dataSource.requestEnd
dataBinding
dataBound
dataSource.change
所有内容都列在documentation中。您还可以使用以下demo。我不确定你想要实现什么,但我怀疑你正试图像解释here一样坚持网格状态。