javascript - Delete rows from Kendo Grid with Pagination -
i have kendo grid(with pagination enabled) entries. say, have 5 pages , have selected(clicked on checkbox) 1 row each page , clicked on top level action delete. not able figure out how delete entries grid , data source?
i tried below code, deletes entries page visible in 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 1 more approach:
i created array of objects remain after deletion operation original array of objects , added grid data source.
var newdata = []; var userselectioninfo = usersservice.getuserselectioninfo(); for(var = 0; < users.length; i++) { if(users[i].username&& !userselectioninfo[users[i].username]) { newdata.push(users[i]); } } loadusersintogrid(newdata);
is there better approach or kendo api missing? in advance.
you can delete datasource instead of grid.first push id of each selected item array, deletelist. can delete datasource on clicking top delete.
for(i=0; i<= deletelist.length; i++) { grid.datasource.remove(grid.datasource.get(deletelist[i])); }
Comments
Post a Comment