分页后丢失已编辑的单元格数据 [英] Losing edited cell data after paging

查看:66
本文介绍了分页后丢失已编辑的单元格数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个完全客户端"的网格,但是如果启用了内联编辑,则在更改网格页面时所做的更改会丢失.

I'm building a completely "client side" grid however if I enable inline editing, the changes I make are lost if I change the grid page.

希望有人可以指出我所缺少的内容

Hopefully someone can point out what I'm missing

下面显示了网格设置以及我调用的将测试数据填充到其中的函数:

The Grid setup is shown below along with the function 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");
}

这显示10页,共100条记录.如果单击"OPT"列,则可以更改文本框中的值,并且单击另一行时,数据似乎已保存.但是,一旦我转到另一页并返回第一页,数据就会恢复为原始值.

This shows 10 pages, 100 records. If I click the "OPT" column, I can change the value in the textbox and when I click another row, the data appears to be saved. However, once I go to another page and back to the first page, the data reverts to its original value.

推荐答案

Oleg-谢谢您一百万.您的答案非常有效.我在官方jqgrid支持论坛上发布了该问题,还有另一种解决方法可能会有所帮助.线程位于 http ://www.trirand.com/blog/?page_id = 393/help/losing-edited-cell-data-after-paging/#p18567 .

Oleg - thanks a million. Your answer works really well. I posted the question on the official jqgrid support forum and there is another workaround which could help. Thread is at http://www.trirand.com/blog/?page_id=393/help/losing-edited-cell-data-after-paging/#p18567.

摘要:如果使用纯客户端代码构建网格,则需要替换

Summary: If building the grid using pure clientside code, you need to replace

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

使用

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

这篇关于分页后丢失已编辑的单元格数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆