jqgrid-用于平面结构数据的treegrid [英] jqgrid - treegrid for flat structure data

查看:78
本文介绍了jqgrid-用于平面结构数据的treegrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将数据以平面结构存储在数据库中,没有任何分层结构,目前使用jqgrid以表格格式显示.我想以向下钻取的方式显示它,例如顶层的计数,以嵌套的方式显示子级.是否可以使用jqgrid ...

我认为进行某些查询的最佳方法是在服务器端使用GROUP BY来构造有关数据层次结构的信息.这样,您将构建所需的树结构.主数据将获得具有父节点"2200"的ID的isLeaf:true, level:4, expanded:false, loaded:true属性和parent属性.如果您将ID用作前缀,例如将'Event'用作'e',将'Model'用作前缀'm',依此类推,则很容易为每一行构造唯一的ID,因此您可以为服务器上的树形网格 ,然后将数据放入服务器响应中.

或者,您只能填充树状网格的顶层.您可以简单地构造查询,以生成结果集.如果用户将打开某些树节点,则新请求将被发送到服务器.该请求将包含一些其他参数:parentidn_level.如果您很好地选择根项的id值,则将具有完整的信息来构造查询,这将使您进入树的下一个层次.您应该使用parentid作为构造查询的WHERE部分.通过这种方式,您还可以构造树并按需加载所有noded.

I have my data stored in database in flat structure with out any heirarchical fashion and currently displaying in tabular format using jqgrid. I would like to display it in drill down fashion like the count at the top levels, child levels like this in nested fashion. Is it possible to do using jqgrid...

解决方案

I think that the best way to make some queries used GROUP BY on the server side to construct the information about the hierarchy of the data. In the way you will be construct the tree structures which you need. The main data will get isLeaf:true, level:4, expanded:false, loaded:true properties and parent property with the id of the parent node "2200". If you would use as ids the values with prefixes like 'e' for 'Event', 'm' for 'Model' and so on you will be easy construct unique ids for every row so you will be able to construct all data for the Tree Grid on the server and then place the data in the server response.

Alternatively you can fill only the top level of the tree grid. You can construct simply query which will produce the resulting set. If the user will opens some tree node the new request will be sent to the server. The request will contains the some additional parameters: nodeid, parentid and n_level. If you good choose the id values of on the root items you will have full information to construct query which will get you the next level on the tree. You should use parentid as to construct the WHERE part of the query. In the way you can also construct the tree and load all noded on-demand.

这篇关于jqgrid-用于平面结构数据的treegrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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