jqgrid重新加载网格部分工作 [英] jqgrid reload grid partially working

查看:71
本文介绍了jqgrid重新加载网格部分工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个客户端管理的jqgrid,在触发某些外部事件时会重新加载. 当我用更多的数据重新加载网格时,一切都很好,但是当我用更少的数据重新加载网格时,行数是不正确的.

I have a client side managed jqgrid that I reload when some external event are fired. Everything is fine when I reload the grid with more data but when I reload it with less data, the amount of rows is incorrect.

例如,当当前在网格中有100行并且我重新加载200行时,导航栏将显示200条记录.如果其中有200行,而我用25行刷新,则它在导航栏中仍显示200,而不是25.刷新网格的代码如下:

For instance, when the is currently 100 rows in the grid and I reload it with 200, then the nav bar shows 200 records. If there are 200 rows in it and I refresh it with 25 rows , it still show 200 in the nav bar instead of 25. The code that refreshes the grid looks like:

 $("#list2").trigger("GridUnload");             
 $.ajax({
   url: 'http://xxx,
   dataType: 'json',
   async: false,
   success: function(data) {
              gridData = data;
          }

});

    $("#list2").setGridParam({ data: gridData });
    $("#list2").trigger("reloadGrid");

我认为导航栏不存在问题,因为我可以清楚地单击下一页并看到添加的行.

I don't think the problem is with the nav bar as I can clearly hit next page and see the addition rows.

谢谢

推荐答案

尝试替换

$("#list2")[0].refreshIndex();
$("#list2").trigger("reloadGrid");

使用

var g = $("#list2");
g.setGridParam({ data: gridData });
g[0].refreshIndex();
g.trigger("reloadGrid");

请参见 http: //www.trirand.com/blog/?page_id=393/help/losing-edited-cell-data-after-paging/通常,就setGridParam方法而言,您应该使用可能设置更好的url参数,或者仅将postData与功能配合使用(请参见

In general you should use probably better set url parameter with respect of setGridParam methods or just use postData with a function (see How to filter the jqGrid data NOT using the built in search/filter box for details)

这篇关于jqgrid重新加载网格部分工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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