jq 网格内联删除

jq Grid inline delete

我正在尝试在 jqGrid 中内联编辑、插入和删除,并成功地插入和编辑但不是删除。我阅读了有关使用 'clientArray' 的文章,它可以实现我在编辑中提到的技巧,但不能用于删除。调用删除功能时,弹出删除消息,但单击删除时,我收到消息:"No url is set".

我做错了什么?这些是单击相应按钮时调用的函数。

function _deleteLine(rowId) {
    var id = rowId;
    if (_.isNumber(id) === false) {
        id = rowId.id;
    }

    self.$grid.delGridRow(id, false, 'clientArray');
}

function _editLine(rowId) {
    var id = rowId;
    if (_.isNumber(id) === false) {
        id = rowId.id;
    }
    self.$grid.jqGrid("editRow", id, true);
    _toggleActionButtons(true, id);
}

function _saveLine(rowId) {
    var defer = $.Deferred();

    var id = rowId;
    if (_.isNumber(id) === false) {
        id = rowId.id;
    }
    self.$grid.saveRow(id, false, 'clientArray');
    toggleActionButtons(false, id);
    return defer.promise();
}

更新:

将删除功能更改为以下内容后,我能够删除该项目,但是,模式不会关闭。我看着这个并跟着它但无法解决:

function _deleteLine(rowId){
options.processing = true;
            var grid_id = $.jgrid.jqID(this.p.id);
            self.$grid.jqGrid("delRowData", rowid);
            $.jgrid.hideModal("#delhd" + grid_id, {
                gb: "#gbox_" + grid_id,
                jqm: true
            });
}

jqGrid 4.6 已经 3 岁了。这是最后一个版本,不支持 delGridRow 本地数据。许多年前,我发布了 the workaround, which describe how one can use the method of form editing to delete line of the local grid. Later I posted another answer,它展示了如何使用其他表单编辑方法来编辑本地行。

一般来说,我会建议更新到 free jqGrid, the fork of jqGrid, which I develop starting with the end 2014. Free jqGrid is compatible to jqGrid 4.6, but many new features allows to simplify the usage of jqGrid. For example, you can use formatter: "actions", inlineNav and call editRow directly. All buttons (inline action buttons and the buttons of navigator menu) will be automatically be hidden/visible or enabled/disabled after starting/ending of editing. No additional calls to show/hide the buttons is required. Try the demo 的最新版本 (4.13.6),例如。