我想要达到的目标是:
到目前为止我做了什么:
function updateChildGridRows(field, operator, value) {
// get the kendoGrid element.
var gridData = $("#childGrid").data("kendoGrid");
var filterField = field;
var filterValue = value;
// get currently applied filters from the Grid.
var currFilterObj = gridData.dataSource.filter();
// if the oject we obtained above is null/undefined, set this to an empty array
var currentFilters = currFilterObj ? currFilterObj.filters : [];
// iterate over current filters array. if a filter for "filterField" is already
// defined, remove it from the array
// once an entry is removed, we stop looking at the rest of the array.
if (currentFilters && currentFilters.length > 0) {
for (var i = 0; i < currentFilters.length; i++) {
if (currentFilters[i].field == filterField) {
currentFilters.splice(i, 1);
break;
}
}
}
if (filterValue != "") {
currentFilters.push({
field: filterField,
operator: "eq",
value: filterValue
});
}
gridData.dataSource.filter({
filters: currentFilters
}); }
我从以下jsfiddle获取此代码:
http://jsfiddle.net/randombw/27hTK/
我已将MasterGrid的Change事件附加到MasterGridSelectionChange()方法。从那里我调用我的过滤方法。
但是当我点击MasterGrid的行时,我的ChildGrid中的所有行都被删除了。
我能理解的一件事是,如果我在过滤器列表中给出错误的列名,则将删除所有行。但即使我给出了正确的ColumnName,我的行也会被删除。
很抱歉这篇长篇文章。
请帮助我解决这个问题,因为我坚持了将近4天!
感谢。