本文介绍了jqGrid 自动加载 Treegrid 问题..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用自动加载树形网格时遇到问题.目前我有一个只有 2 层深的结构.

1一种乙C2一种

当我点击展开一个节点时,网格似乎再次添加了根节点的另一个实例,以及根据选择的根节点应该显示的任何子节点.

11一种乙C

在选择根节点之前先看一下

这里是选择根节点后的

另外,这是我的配置:

$(document).ready(function(){$("#gReport").jqGrid({树格:真,treeGridModel: '邻接',ExpandColumn: '公司',网址:document.forms['frmReport'].elements['gaddr'].value,数据类型:'

任何帮助将不胜感激.谢谢.-克里斯

解决方案

你描述的行为真的很有趣!问题是子节点Child 1"未标记为叶( 后面的行 是 isLeaf 值).因此,在用户单击Child 1"之后,必须显示其所有子项.由于已加载"列的值未在您的输入中定义,因此树形网格尝试从服务器加载 id=5207 的Child 1"节点的子节点.所以对同一个url的请求带有附加参数

nodeid=5207&parentid=1112&n_level=1

将完成.因为您的服务器只是忽略参数并返回相同的

(请参阅)或在具有true"值的已加载"列的

<单元格>1112</单元格><细胞>亲本1</细胞><单元格>0</单元格><单元格>NULL</单元格><单元格>假</单元格><!-- 是叶子--><单元格>真</单元格><!-- 应该扩展--><单元格>真</单元格><!-- 已加载--></row><细胞>5207</细胞><单元格>孩子1</单元格><单元格>1</单元格><单元格>1112</单元格><单元格>假</单元格><!-- 是叶子--><单元格>假</单元格><!-- 应该扩展--><单元格>真</单元格><!-- 已加载--></row>

并接收网格

(参见).我建议您以任何方式为加载"列包含真"值.您获得的额外优势是您将能够扩展任何节点在加载时.例如,在上一个演示中,我在根节点的扩展"列中设置了真"值,因此它将在加载时扩展.

I am having a problem with an autoloading tree grid.At present I have a structure that is only 2 levels deep.

1
    a
    b
    c
2
    a

When I click to expand a node, the grid seems to add another instance of the root node again as well as whichever sub node(s) should have been shown based on the the root node selected.

1
1
    a
    b
    c

Here is a look at the

<?

And here is a look at the

<?

Also, here is my config:

$(document).ready(function(){
    $("#gReport").jqGrid({
        treeGrid: true,
        treeGridModel: 'adjacency',
        ExpandColumn: 'company',
        url: document.forms['frmReport'].elements['gaddr'].value,
        datatype: '

Any help would be greatly appreciated.Thanks.-chris

The behavior which you described is really funny! The problem is that the child node "Child 1" is not marked as leaf (the line <cell>false</cell> after the <cell>1112</cell> is the isLeaf value). So after the user click on the "Child 1" all its children must be shown. Because the value for the column "loaded" is not defined in your input the tree grid try to load the children of the "Child 1" node having id=5207 from the server. So the request to the same url with additional parameters

will be done. Because your server just ignore the parameters and get the same

(See the demo ).To fix the problem you should either mark the "Child 1" node as the leaf:

<row>
    <cell>5207</cell>
    <cell>Child 1</cell>
    <cell>1</cell>
    <cell>1112</cell>
    <cell>true</cell> <!-- here the "false" was changed to "true" -->
    <cell>false</cell>
</row>

and receive the following tree grid

(see the demo ) or add additional data in the

<row>
    <cell>1112</cell>
    <cell>Parent 1</cell>
    <cell>0</cell>
    <cell>NULL</cell>
    <cell>false</cell> <!-- is leaf -->
    <cell>true</cell>  <!-- should be expanded -->
    <cell>true</cell>  <!-- is loaded -->
</row>
<row>
    <cell>5207</cell>
    <cell>Child 1</cell>
    <cell>1</cell>
    <cell>1112</cell>
    <cell>false</cell> <!-- is leaf -->
    <cell>false</cell> <!-- should be expanded -->
    <cell>true</cell>  <!-- is loaded -->
</row>

and receive the grid

(see the demo ). I would recommend you to include "true" value for the "loaded" column in any way. The additional advantage which you receive is that you will be able to expand any node at the load time. In the last demo for example I set "true" value in the "expanded" column for the root node, so it will be expanded at the load time.

这篇关于jqGrid 自动加载 Treegrid 问题..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!