且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在jqGrid的风格inlineNav添加新的空行

更新时间:2023-12-01 13:50:28

首先没有回调函数 addRowData ​​ code>。如果你想修改的方法 addRowData ​​A>支持 afterSelected'或'beforeSelected'你应该遵循我的建议从答案或的这个的演示

First of all there are no callback function addRowData. If you want to modify the method addRowData to support 'afterSelected' or 'beforeSelected' you should follow my suggestion from the answer or this one with the demo.

现在你的主要问题。内部使用的 inlineNav 方法的addRow 并的 editRow 方法。所以,如果添加或编辑按钮,以 inlineNav 一中添加的用户点击> addRow 或的 editRow 将被调用。您可以使用的 addParams 和 editParams 选项/doku.php?id=wiki%3ainline_editing#inlinenav\">inlineNav 改变的 addRow editRow 。如果你只需要指定自己的回调函数将被调用时,在用户点击添加或编辑按钮,您可以使用下面的code:

Now about your main question. The inlineNav method used internally addRow and editRow methods. So if the user click on "Add" or "Edit" button added by inlineNav the addRow or editRow will be called. You can use addParams and editParams options of inlineNav to change the default parameters of addRow or editRow. If you just need to specify your own callback function which will be called when the user click on Add or Edit button you can use the following code:

$("#list").jqGrid('inlineNav', '#pager', {
    edittext: "Edit",
    addtext: "Add",
    savetext: "Save",
    canceltext: "Cancel",
    addParams: {
        position: "afterSelected",
        addRowParams: {
            // the parameters of editRow used to edit new row
            keys: true,
            oneditfunc: function (rowid) {
                alert("new row with rowid=" + rowid + " are added.");
            }
        }
    },
    editParams: {
        // the parameters of editRow
        key: true,
        oneditfunc: function (rowid) {
            alert("row with rowid=" + rowid + " is editing.");
        }
    }
});

此外,你或许应该删除 onSelectRow 回调code。如果你需要使用 inlineNav $ C $的编辑按钮C>。

Additionally you should probably remove the code of the onSelectRow callback if you need to use Edit button of inlineNav.