简体   繁体   English

在extjs treegrid中实现自定义json

[英]Implement Custom json in extjs treegrid

I am trying to implement a code where I need to display data from a JSON into a tree grid, but I am unable to get the desired output. 我正在尝试实现一个代码,该代码需要将JSON中的数据显示到树状网格中,但是我无法获得所需的输出。 I only see the root node, and when I click on it again, it copies the same node into the second one. 我只看到根节点,再次单击它时,它将同一节点复制到第二个节点中。

My JSON looks like below: 我的JSON如下所示:

{
  "grandparent": [
    {
      "parent1": [
        {
          "parent2": [
            {
              "parent3": [],
              "id": "aa",
              "name": "abc",
              "grandparentid": "11",
              "specialparams": [
                {
                   "a": "04",
                  "y": "",
                  "x": "asd_123",
                  "z": 0,
                    }]
                  }
               }
               name="text",
               "grandparentid": "11"    
               }

In my store, I have mentioned rootProperty as 'grandparent'. 在我的商店中,我提到过rootProperty是“祖父母”。 Not sure what I am missing. 不知道我在想什么。

Expected Output: 预期产量:

>grandparent
 >parent1
  >parent2
   >parent3 -- this will be blank
   a:04
   x:asd_123

In tree store if you want the node to have child nodes you should set child nodes in children property. 在树存储中,如果您希望节点具有子节点,则应在children属性中设置子节点。

In your JSON there is no children for each node and you defined nodes as array 在您的JSON ,每个node没有children node并且您将节点定义为array

Make your JSON like: 使您的JSON像这样:

[
{
    id: 1,
    name: "grandparent"
    children: [
        {
            id: 2,
            name: "parent1",
            children: [
                {
                    id: 3,
                    name: "parent2",
                    children: [
                        ...
                    ]
                }
            ]
        }
    ]
}
]   

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM