jqGrid.带有本地数据和特殊字段“已加载"的树形网格 [英] jqGrid. Tree grid with local data and special field "loaded"

查看:142
本文介绍了jqGrid.带有本地数据和特殊字段“已加载"的树形网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有本地数据的树形网格.而且,我对可以改善网格性能和设计的最佳实践很感兴趣.因此,我找到了一条相关的帖子,我想知道在什么情况下传递未声明的属性"loaded:true "作为数据源. 非常感谢您的回答(尤其是@Oleg的回答:)).

I'm using a tree grid with local data. And I'm interesting in best practices that can improve performance and design of my grid. So I found a related post and would like to know in what case it can be useful to pass undeclared property "loaded:true" as a data source. I'd appreciate your answers (especially @Oleg answer :)).

推荐答案

TreeGrid最初是实现的,因此它在jqGrid的隐藏列中保存了有关树结构的所有其他信息.后来jqGrid开始支持本地数据,但是每行中仍然存在隐藏的列.

TreeGrid was implemented originally so that it holds all additional information about the tree structure in hidden columns of jqGrid. Later jqGrid starts to supports local data, but the hidden columns still exists in every row.

旧版本的TreeGrid只能从服务器加载数据.在开始时,jqGrid仅需要加载根节点(父节点为null的节点).如果需要扩展节点,则带有附加参数nodeidparentidn_level(或在使用treeGridModel: "nested"的情况下为nodeidn_leftn_rightn_level)的新Ajax请求将发送到url.服务器应基于参数返回数据.一旦数据被加载并且节点需要折叠,将使用display: none CSS样式对子节点进行隐藏.下次jqGrid不应再次从服务器加载数据.代替该jqGrid只是显示该节点的子代.正是在父节点的loaded列(隐藏列)将保存true值的情况下.

Old versions of TreeGrid can load only the data from the server. At the beginning jqGrid needs to load only the root nodes (the nodes which parent is null). If the node need be expanded then new Ajax request with additional parameters nodeid, parentid and n_level (or nodeid, n_left, n_right, n_level in case of usage treeGridModel: "nested") will be sent to url. The server should returns the data based on the parameters. Once the data will be loaded and the node need be collapsed the children will be make just hidden using display: none CSS style. Next time jqGrid should don't load the data from the server once more. Instead of that jqGrid just show children of the node. Exactly in the case the loaded column (the hidden column) of the parent node will hold true value.

在使用本地数据创建TreeGrid的情况下,所有工作均与上述完全相同.遗憾的是,TreeGrid到目前为止尚不支持datatype: "local",但是使用datatype: "jsonstring"几乎可以实现相同的功能.您在问题中引用的我的旧答案说明了该方法.由于jqGrid(TreeGrid)的结构仍面向远程加载,因此只需在数据的所有节点上设置loaded:true属性即可.结果,远程TreeGrid可以正常工作,而无需与服务器进行任何其他通信.所有数据将立即加载,但折叠的节点填充将跟随隐藏的子项.

In case of creating TreeGrid with local data all works exactly like described above. It's a pity, but TreeGrid don't support datatype: "local" till now, but one can do almost the same by usage datatype: "jsonstring". My old answer which you referenced in your question demonstrates the approach. Because the structure of jqGrid (TreeGrid) is still oriented of remote loading one should just set loaded:true property on all nodes of the data. As the result the remote TreeGrid works without any additional communication with the server. All the data will be loaded at once, but collapsed node fill follows hidden children.

所以可以说,loaded:true属性的使用是一种黑客,它可以立即加载所有TreeGrid数据,并且可以使节点后期扩展或崩溃,而无需与服务器进行任何其他通信.

So one can say, that the usage of loaded:true property is a hack which allows to load all TreeGrid data at once and to make late expanding or collapsing of nodes without any additional communication with the server.

这篇关于jqGrid.带有本地数据和特殊字段“已加载"的树形网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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