jqgrid - Delete multiple selected rows

倾然丶 夕夏残阳落幕 提交于 2019-12-25 02:55:17

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/29827453/jqgrid-delete-multiple-selected-rows

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!