0

I'm trying to delete multiple selected rows. I implemented the multiple selection in the way described here: https://stackoverflow.com/a/4186851/1844996

My code for deletion is as follows:

element.jqGrid('navGrid', pagerId,
    { edit:false, add:false, search:false, del:true, refresh:true },
    /*editParams*/{
    },
    /*addParams*/{
    },
    /*deleteParams : */{
        mtype: 'DELETE',
        onclickSubmit: function (params, postdata) {
            var rowids = postdata.split(",");                
            for (var i = 0; i < rowids.length; i++) {
                var id = rowids[i];                                        
                var uniqueId = element.jqGrid('getCell', id, uid);                    
                params.url = url + '/' + encodeURIComponent(uniqueId);
            }
        },
        serializeDelData: function () {
            return ''; // don't send and body for the HTTP DELETE
        }
    }
);

When only one row is selected, DELETE HTTP request is sent to server and everything works like a charm. However, for multiple selection every uniqueId is created fine but only one DELETE HTTP is sent with the last selected row. Any idea how to overcome this and fire separate DELETE HTTP for each row?

Community
  • 1
  • 1
Filip
  • 2,244
  • 2
  • 21
  • 34

1 Answers1

0

I managed to implement it slightly different. Instead of firing many DELETE HTTP requests, i am firing one with comma-separated deletion id values set in url.

params.url = url + '/' + [uniqueIds]

and deletion logic is handled on server. Everything is resolved with single HTTP DELETE.

Filip
  • 2,244
  • 2
  • 21
  • 34