How To Select Kendo Grid Row If That Row Is Not Present On First Page Of The Kendo Grid./
Tried to select a kendo grid row in dataBound (Note: that row is not on first page of the grid) but it didn't selected 3rd page row. dataBound: function(e) { if (id!==
Solution 1:
Below function is for finding dataItem and selection of any page row.
Var initial prevents the databound to get called after first call.
functionfindDataItem(ragGrid, dataItem) {
initial = true;
var ds = ragGrid.dataSource;
var view = window.kendo.data.Query.process(ds.data(), {
filter: ds.filter(),
sort: ds.sort()
}).data;
var index = -1;
for (var x = 0; x < view.length; x++) {
if (view[x].Id == dataItem.Id) {
index = x;
break;
}
}
if (index === -1) {
return;
}
var page = Math.floor(index / ragGrid.dataSource.pageSize());
var targetIndex = index - (page * ragGrid.dataSource.pageSize())+ 1;
ragGrid.dataSource.page(++page);
var row = $("#ragGrid").find("tr:eq(" + targetIndex + ")");
ragGrid.select(row);
}
Here is the dataBound function and calling findDataItem in dataBound first call.
dataBound: function (e) {
if (id !== "" && id !== undefined && id !== null) {
if (!initial){
var grid = e.sender;
var data = grid.dataSource.data();
var res = $.grep(data, function (d) {
return d.Id == id;
});
findDataItem(grid, res[0]);
}
}
},
Post a Comment for "How To Select Kendo Grid Row If That Row Is Not Present On First Page Of The Kendo Grid./"