Loss of edited cell data after swapping

I build a completely β€œclient” grid, however, if I enable inline editing, the changes I make are lost if I change the grid page.

Hope someone can point out what I am missing

Below is a grid diagram along with the function that I call to fill it with test data:

var myGrid;
var lastgridsel;
jQuery(document).ready(function() {
    myGrid = jQuery("#mygrid").jqGrid({
        datatype: 'local',
        colModel: [
            { name: 'AID', label: 'AID', index: 'AID', width: 100, editable: false,
              sorttype: "int" },
            { name: 'MS', label: 'MS', index: 'MS', width: 300, editable: false },
            { name: 'GROUP', label: 'GROUP', index: 'GROUP', width: 100,
              editable: false },
            { name: 'REV', label: 'REV', index: 'REV', width: 100,
              editable: false },
            { name: 'OPT', label: 'OPT', index: 'OPT', width: 100, editable: true,
              edittype: 'text' }
        ],
        pager: '#mypager',
        rowNum: 10,
        rowList: [10, 20, 500],
        viewrecords: true,
        loadonce: true,
        autowidth: true,
        sortname: 'AID',
        sortorder: 'desc',
        cellsubmit: 'clientArray',
        onSelectRow: function(id) {
            if (id && id !== lastgridsel) {
                jQuery('#mygrid').saveRow(lastgridsel, false, 'clientArray');
                jQuery('#mygrid').editRow(id, true);
                lastgridsel = id;
            }
        }
    });
});

var mydata = [];
function InitNew() {
    for (var i = 0; i < 100; i++) {
        mydata.push({ AID: i, MS: "123", GROUP: "456", REV: "78", OPT: "8" });
    }
    myGrid.setGridParam({ data: mydata }).trigger("reloadGrid");
}

It shows 10 pages, 100 entries. If I click on the "OPT" column, I can change the value in the text box, and when I click on another row, the data will be saved. However, as soon as I go to another page and return to the first page, the data will return to the original value.

+1
source share
2 answers

- . . jqgrid, , . http://www.trirand.com/blog/?page_id=393/help/losing-edited-cell-data-after-paging/#p18567.

. ,

myGrid.setGridParam({ data: mydata }).trigger("reloadGrid");

myGrid.setGridParam({ data: mydata });
myGrid[0].refreshIndex();
myGrid.trigger("reloadGrid");
0

, ​​ 3.7.x , , ( saveRow editRow), jqGrid .

,

var myAfterSave = function(rowid, response) {  // aftersavefunc
    var index = parseInt(rowid, 10);
    var d = myGrid.getGridParam("data");
    var rowdata = myGrid.getRowData(rowid);
    d[rowdata.AID].OPT = rowdata.OPT;
};

jQuery('#mygrid').saveRow(lastgridsel, false, 'clientArray');
jQuery('#mygrid').editRow(id, true);

jQuery('#mygrid').saveRow(lastgridsel, false, 'clientArray', null, myAfterSave);
jQuery('#mygrid').editRow(id, true, null, null, 'clientArray', null, myAfterSave);
+2

All Articles