Jqgrid adding new blank row in inlineNav style

前端 未结 1 1197
花落未央
花落未央 2021-01-15 14:38

I would like to create Add Edit Save And Delete button below my JqGrid.



        
相关标签:
1条回答
  • 2021-01-15 15:12

    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.

    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.");
            }
        }
    });
    

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

    0 讨论(0)
提交回复
热议问题