Django,Javascript

JqGrid delete multiple select rows

1 Apr , 2015  

There is an issue if we delete rows using :

1
2
3
4
5
6
7
8
9
10
// Get all selected row
var rows = $(selector).jqGrid("getGridParam", "selarrrow");
console.log(rows);

// Iterate and delete
for (var i in rows) {
      console.log(i);
      console.log(rows[i]);
      $(selector).jqGrid('delRowData', rows[i]);
}

Only a few records will deleted.

The solution :

1
2
3
4
5
6
7
8
9
10
11
12
13
/**
 * Delete data button handler
 * There is a bug if we delete by forloop, solution
 * http://www.trirand.com/blog/?page_id=393/bugs/delrowdata-bug-on-grid-with-multiselect
 */
$("a.delete-data").click(function(e) {
    e.preventDefault();

    var rowids = $(selector).jqGrid('getGridParam', 'selarrrow');
    for (var i = rowids.length - 1; i >= 0; i--) {
        $(selector).jqGrid('delRowData', rowids[i]);
    }
});


2 Responses

  1. seonhwa says:

    ThankU 🙂

  2. Andres says:

    Muchas gracias justo lo que buscaba.

Leave a Reply

Your email address will not be published. Required fields are marked *