How to supply a Row ID when using jqGrid 'editGridRow' to create a new row and not the auto generated Row ID jqg1

后端 未结 1 352
醉酒成梦
醉酒成梦 2020-12-12 06:47

I\'m new to jqGrid, so hopefully someone can point me in the right direction.

Basically, I am using jgGrid to display a list of dates and costs that I have read in f

相关标签:
1条回答
  • 2020-12-12 07:01

    I am not quite understand your requirement. You get the input for the jqGrid from the server, but use datatype: "local" instead of the datatype: "json" for example which instruct jqGrid to get ajax request to the server to get the data whenever as needed. Moreover you want to save the date on the server, but use editurl: '/dummyurl' instead of the real server url. The editurl would get the input data from the $("#tableGrid").jqGrid('editGridRow', "new", {reloadAfterSubmit:false}); and should post back the id of the new generated row. Is it not what you want?

    So my suggestion would be to use some server based datatype (the bast is datatype: "json") and in the same way use real editurl which save the data on the server (in the database mostly) and place in the server response the id on the new generated data item.

    UPDATED: If you use reloadAfterSubmit: false option of the editGridRow you have to use afterSubmit event handler together with reloadAfterSubmit which decode the server response and return the result in the format [true,'',new_id] For example if your server just return new rowid as the data you can use

    $("#tableGrid").jqGrid('editGridRow', "new",
        {
            reloadAfterSubmit: false,
            afterSubmit: function (response) {
                return [true, '', response.responseText];
            }
        }
    );
    
    0 讨论(0)
提交回复
热议问题