子网格缓存或停止删除子网格数据(jqGrid) [英] Subgrid Caching or Stopping Subgrid data from being removed (jqGrid)

查看:135
本文介绍了子网格缓存或停止删除子网格数据(jqGrid)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法强制jqGrid在切换行时不删除子网格数据?我当前的加载数据网格的过程如下:

Is there any way to force jqGrid not to remove the subgrid data when its row is toggled? My current process for loading the datagrid is as follows:

1)设置主网格,使用我以后可以使用的ID以编程方式设置子网格

1) Setup main grid, setting subgrid up programatically with an ID that I can use later

2)通过json在本地将数据加载到主网格中

2) Load data into main grid locally via json

3)通过json在本地将数据添加到子网格

3) Add data to subgrid locally via json

由于以下事实:当用户切换(隐藏然后重新显示)时,我在本地而不是通过URL加载子网格,因此网格中没有任何数据,我希望它显示提供的原始数据到子网格.

Due to the fact that I am loading the subgrid locally instead of by a URL when the user toggles (hides then redisplays) the grid doesn't have any data in it and I want it to display the original data that was provided to the subgrid.

我知道这似乎是加载数据的一种怪异方法,但这是有原因的

I know that this may seem like a weird way of loading the data, but there is a reason

我目前使用jqGrid所做的是在单个网页上显示大量的保险信息(本质上是报告).该网页应自动加载所有数据,并且我有很多实例需要提供子网格功能.我已经想出了如何通过手动强制发生click事件来显示子网格的方法,但是再次,如果用户单击子网格,它就会消失并且不会回来.

What I am currenty doing with jqGrid is displaying tons and tons of insurance information on a single web page (essentially it is a report). This web page should load all of the data automatically and I have many instances where I need to provide subgrid functionality. I have figured out how I can do this by manually forcing the click event to occur so that the subgrid will be displayed, but again, if the user clicks on the subgrid then it disappears and doesn't come back.

如果您对此有任何建议,请告诉我.

If you have any suggestions for this please let me know.

此外,如果您认为有更好的方法来自动显示所有数据,请也告诉我.到目前为止,我发现jqGrid易于使用,但是我一直在强迫它执行它本来没有做的事情,例如在页脚行中添加总值.

Also, if you think there are better ways of getting all of the data to display automaticaly please let me know that as well. So far I have found jqGrid to be easy to work with, but I have been forcing it to do things that it didn't natively do, like adding total values in the footer row.

在此先感谢您的帮助.

推荐答案

您想要做的是防止jqGrid在扩展行时重新加载子网格数据.控制旋钮在jqGrid的subGridOptions属性中. subGridOptions对象具有一个名为reloadOnExpand的布尔属性,该布尔属性可控制此确切行为.

What you want to do is to prevent jqGrid from reloading subgrid data when a row is expanded. The control knob for this is in the subGridOptions property of the jqGrid. The subGridOptions object has a boolean property called reloadOnExpand which controls this exact behavior.

初始化jqGrid对象时,只需确保将此属性设置为false,如下所示:

When you initialize your jqGrid object, just make sure to set this property to false, as below:

jQuery("#gridId").jqGrid({
    // ... other properties ...
    subGrid: true,
    subGridOptions: {
        reloadOnExpand: false // Prevent jqGrid from wiping out the subgrid data.
    },
    subGridRowExpanded: subGridExpandCallback,
    // ... other properties ...

我唯一能找到此代码的地方是通过在其演示站点的页面上执行查看源代码"来提及此行为.发布此内容时的演示页面位于: http://www.trirand.com/blog/phpjqgrid/examples/hierarchy/subgrid_loadonce/default.php

The only place I could find this code was by doing a "View Source" on the page at their demo site that mentions this behavior. The demo page at the time of this posting is here: http://www.trirand.com/blog/phpjqgrid/examples/hierarchy/subgrid_loadonce/default.php

这篇关于子网格缓存或停止删除子网格数据(jqGrid)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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