The 'deleteRow' method require a 'index' parameter that represent the row index. Please pass a correct parameter value while calling this method. The example below shows how to delete all selected rows.
var rows = $('#tt').datagrid('getSelections'); // get all selected rows
for(var i=0; i<rows.length; i++){
var index = $('#tt').datagrid('getRowIndex',rows[i].id); // get the row index
$('#tt').datagrid('deleteRow',index);
}
this doesn't work for me... when first row was removed, the index doesn't correspond to the selected rows...
For Example: When you have selected 4 rows (1,2,3,4) and you remove row 1 (index 0) so row 2 becomes now row 1 (index 0) and so on...
For that Reason i push every index first in an array... then sort it and reverse it so that the first index to be removed is the last...
then all lower indexes remain unchanged until you remove it...
so i had to modify it like this below:
var rows = $('#tt').datagrid('getSelections'); // get all selected rows
var ids = [];
for(var i=0; i<rows.length; i++){
var index = $('#tt').datagrid('getRowIndex',rows[i]); // get the row index
ids.push(index);
}
ids.sort(); // sort index
ids.reverse(); // sort reverse
for(var i=0; i<ids.length; i++){
$('#tt').datagrid('deleteRow',ids[i]);
}