have a kendo grid(with pagination Enabled) with some entries. Say, I have 5 pages and I have selected(clicked on checkbox) one row from each page and then clicked on top level action DELETE. I am not able to figure out how to delete the entries from the grid and the data source?
I tried below code, which deletes the entries from the page which is visible in the grid (on screen)
var grid = $("#grid").data("kendoGrid");
var userSelectionInfo = usersService.getUserSelectionInfo();
for(var userName in userSelectionInfo) {
if(userSelectionInfo[userName]) {
var selector = '#' + userName+ '_actions';
grid.removeRow($(selector).closest('tr'));
}
}
I tried one more approach:
I created an array of objects which will remain after deletion operation from the original array of objects and then added into the grid data source.
var newData = [];
var userSelectionInfo = usersService.getUserSelectionInfo();
for(var i = 0; i <
users.length
; i++) {
if(users[i].userName&& !userSelectionInfo[users[i].userName]) {
newData.push(users[i]);
}
}
loadUsersIntoGrid(newData);