发生删除行时会触发哪个事件?

Which event gets fired when delete row occurs?

网格包含保存行事件后 "jqGridInlineAfterSaveRow",如果您编辑或添加行,该事件将起作用。

                //--Bind events...
            console.log('Bind events...');
            $("#jqGrid").bind("jqGridInlineAfterSaveRow",function (e, rowid, jqXhrOrBool, postData, options) {
                console.log('EVENT:jqGridInlineAfterSaveRow');
                var item = $(this).jqGrid('getLocalRow', rowid);
                console.log(item);
                console.log('BEFORE:');
                saveObject(item);
                console.log('AFTER:');
            }); 

删除行的事件名称是什么?我需要绑定我的 JS 函数来删除行。

更新 1 我现在正在尝试以下选项,但运气不好...

                    }).jqGrid("navGrid", "#jqGridPager", {edit: false, add: false, del: false, refresh: false, view: false,search: false,
                                                      delfunc: function (rowids) {
                                                          console.log(rowids);
                                                      }
                                                     })

更新 2 我认为问题在于行级别的删除按钮而不是 footer 查看屏幕截图[在此处输入图片描述][1]

                        data:rdata,
                    colModel: [
                        {
                            label: "",
                            name: "",
                            width: 70,
                            formatter: "actions",
                            formatoptions: {
                                keys: true,
                                editOptions: {},
                                addOptions: {},
                                delOptions: {                        delfunc : function (id){
                                    console.log(">>>>>>>>>>>>>>>>1");
                                }}
                            }       
                        },

更新 3 根据 Oleg 的意见,我将代码更改如下:

                $("#jqGrid").bind("jqGridAfterDelRow",function (e, rowid, jqXhrOrBool, postData, options) {
                console.log('EVENT:jqGridAfterDelRow');
                console.log(rowid);
                var item = $(this).jqGrid('delRowData ', rowid);
                console.log(item);
                console.log('BEFORE:');

                console.log('AFTER:');
            });   

但是现在,我没有得到已删除的行对象???实际上,我需要从已删除的行中获取一些字段,例如ID。以上绑定函数会依次调用服务器端ajax函数。

更新 4 感谢 Oleg 对 beyond...的支持...这是我从他的一个答案中混搭而成的代码。

                        colModel: [
                        {
                            label: "",
                            name: "",
                            width: 70,
                            formatter: "actions",
                            formatoptions: {
                                keys: true,
                                editbutton : true, 
                                delbutton : true, 
                                editOptions: {},
                                addOptions: {},
                                delOptions: {
                                    onclickSubmit: function(options, rowid) {
                                        console.log("delOptions::onclickSubmit"); 
                                        var grid_id = $.jgrid.jqID(grid[0].id);
                                        var grid_p = grid[0].p;
                                        var newPage = grid[0].p.page;
                                        var rowdata = grid.getLocalRow(rowid);

                                        // DELETE GRID LOCAL ROW
                                        grid.delRowData(rowid);
                                        $.jgrid.hideModal("#delmod"+grid_id,
                                                          {gb:"#gbox_"+grid_id,jqm:options.jqModal,onClose:options.onClose});                                            

                                        if (grid_p.lastpage > 1) {// on the multipage grid reload the grid
                                            if (grid_p.reccount === 0 && newPage === grid_p.lastpage) {
                                                // if after deliting there are no rows on the current page
                                                // which is the last page of the grid
                                                newPage--; // go to the previous page
                                            }
                                            // reload grid to make the row from the next page visable.
                                            grid.trigger("reloadGrid", [{page:newPage}]);
                                        }

                                        return true;
                                    },
                                    processing:true
                                }
                            }       
                        },

要删除行,请使用以下代码段: $('#gridId').jqGrid('delRowData',rowid);

您也可以使用 "jqGridAddEditAfterComplete" event, which will be triggered after deleting of rows by delGridRow, or you can use "jqGridAfterDelRow",因为 delGridRow 在内部调用 delRowData,而 jqGridAfterDelRow 将由 delRowData 触发。

 $("#yourGridTable").jqGrid(
    "navGrid",
    "#yourGridTablePager",
    {
      del: true
    },
    {},
    {},
    {
      // This event is fired when delete button is pressed in pager 
      //
      beforeSubmit:function(){
          console.log("After delete button of pager is clicked");
      }
    }
);