jqGrid 将单元格数据放入 delOptions 属性中

jqGrid get cell data into delOptions property

本文关键字:delOptions 属性 单元格 数据 jqGrid      更新时间:2023-09-26

我有一个colModel列,当用户按下按钮时,它将删除该行。但是,我需要它去服务器(确实如此)并使用行的 ID 将其从数据库中删除。

这是执行此操作的代码

      colModel: [
           ...
            { name: 'id', index: 'Id', width: 70, hidden: true, editable: true, 
            {
                name: 'actions', index: 'actions', width: 20, sortable: false, editable: false, formatter: imageFormat,
                formatoptions: {
                    keys: true,
                    editbutton: false,
     // I need to pass id from above into the server....this is what should happen here
                    delOptions: { url: Controller + 'Action?paramenter=' + id}
                }
            },
        ],

问题是我需要获取 id 列的值并将其传递给上面的参数。

如何做到这一点?

谢谢

好的,

我没有使用delOptions我在 onSelectRow 属性中使用了 .jqGrid('delGridRow') 方法,

并获取我使用的ID。

var myGrid = $('#grid'),
selRowId = myGrid.jqGrid('getGridParam', 'selrow'),
celValue = myGrid.jqGrid('getCell', selRowId, 'name');

所以因此...

 jQuery("#resume").jqGrid('delGridRow', id, { height: 480, width: 400, closeAfterAdd: true, closeAfterEdit: true, recreateForm: true,url: Controller + 'Action?paramenter=' + celValue });

使用 loadComplete() 方法,你可以这样做:

$(table).find(".ui-inline-del").each(function() {
var delDivBtn = $(this);
var id_reg = /('w+)([_]{1})('w+$)/;
// remove the delete event
$(delDivBtn).removeAttr("onclick");
// add new click event 
$(delDivBtn).click(function() {
    var rowid = delDivBtn.attr("id").replace(id_reg, '$3');
    alert(rowid);
});

});