Rahman Usta Rahman Usta - 11 months ago 57
jQuery Question

After Save or Edit JqGrid doesn't refresh the records

Im using JqGrid to list, add, delete, edit, find the my records. When i choose the loadonce=false, it normally refresh the records after del, edit or add. But, paging and searching mechanisim doesnt works. Once i choose the loadonce=true, it refresh the records after delete, not after add or edit. And then paging and searching runs normally in loadonce=true mode. i tried the;

$("#list").setGridParam({datatype:'json', page:1}).trigger('reloadGrid');


afterInsertRow: function (rowid,rowdata,rowelem){
alert("hello"); // this wasnt invoked

but they didnt solve my problem.

What's the reason my problem.

Answer Source

If you use loadonce: false than you have to implement paging, sorting and searching on the server side. If paging and searching are not working, then you don't implemented the features in your current server code.

The option reloadAfterSubmit specify whether the grid will be reloaded after editing.

If you use loadonce: true the datatype will be changed to 'local' after the first load. The problem is that jqGrid don't support local form editing. So you have to implement the server part for Add/Edit/delete. The problem is that reloading in the case will be executed local and not from the server. To reload the data from the server after end of form editing you can reset the datatype to the initial state ('json' or 'xml') inside of afterSubmit callback. In the case the next reloading (in case of reloadAfterSubmit: true) will be done from the server like you as want.

UPDATED: The following code of afterSubmit should solve the problem:

afterSubmit: function () {
    $(this).jqGrid("setGridParam", {datatype: 'json'});
    return [true];