How to post variable data with editData or onclickSubmit in jqgrid

前端 未结 2 991
生来不讨喜
生来不讨喜 2020-12-22 03:37

I can\'t get editData or onclickSubmit to do what I need.

I want the grid to follow the added or edited row after update. So, I need to post some additional info so

相关标签:
2条回答
  • 2020-12-22 03:44

    I think this should do exactly what you want, it changes the postData variable that is sent to the controller, and then triggers a reload.

    $('#gridName').jqGrid('setGridParam', { postData: { KeyName: KeyValue } }).trigger('reloadGrid', [{ page: 1}]);
    

    if you need it to go as part of your edit you can do almost the same thing

    $(#gridName).jqGrid('editGridRow', rowid, { editData: { KeyName: KeyValue
    
    0 讨论(0)
  • 2020-12-22 03:48

    You can either define properties of editData using functions

    editData: {
        sortColumnName: function () { return "ProductName"; },
        sortOrder: function () { return "asc"; },
        rowNum: function () { return 15; }
    }
    

    or use callback onclickSubmit to extend the data posted to the server

    onclickSubmit: function (options, postData) {
        return {
            sortColumnName: "ProductName",
            sortOrder: "asc",
            rowNum: 15
        };
    }
    

    or use serializeEditData callback

    serializeEditData: function (postData) {
        return $.extend(true, {}, postData, {
            sortColumnName: "ProductName",
            sortOrder: "asc",
            rowNum: 15
        });
    }
    

    Every from above ways do the same. You can choose one way which you find the mostly convenient for your requirements.

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