Webix没有显示动态加载的孩子数据

时间:2018-03-28 12:56:45

标签: webix webix-treetable

我正在使用webix来显示一些树表数据。

     webix.ready(function () {
            grida = webix.ui({                        
                container: "testB",
                view: "treetable",
                columns: [
                    { id: "id", header: "", css: { "text-align": "right" } },
                    {
                        id: "SerialNo", header: "Serial No", width: 250,
                        template: "{common.treetable()} #SerialNo#"
                    }
                ],
                url: "/Test/GetTreeItem",
                autoheight: true,
            });
        });

这样可以完美地加载项目。

父母;

[{"id":11583,"Id":11583,"SerialNo":"12476127654","webix_kids":1},{"id":11584,"Id":11584,"SerialNo":"125235463","webix_kids":1},{"id":11585,"Id":11585,"SerialNo":"21385423348956","webix_kids":1},{"id":11586,"Id":11586,"SerialNo":"253346346346","webix_kids":1},{"id":11587,"Id":11587,"SerialNo":"123123","webix_kids":1},{"id":11588,"Id":11588,"SerialNo":"52354263","webix_kids":1},{"id":11589,"Id":11589,"SerialNo":"12344444","webix_kids":1},{"id":11590,"Id":11590,"SerialNo":"12344444","webix_kids":1},{"id":11591,"Id":11591,"SerialNo":"12344444","webix_kids":1},{"id":11592,"Id":11592,"SerialNo":"151515","webix_kids":1}]

然而,当我单击加号按钮时,服务器返回(我可以在调试代码时看到json字符串)json,但是webix没有将数据附加到父级下面。

父母的孩子" id":11587;

[{"id":11583,"Id":11583,"SerialNo":"12476127654","webix_kids":1},{"id":11592,"Id":11592,"SerialNo":"151515","webix_kids":1}]

2 个答案:

答案 0 :(得分:0)

数据对象的id必须是每个组件唯一的。

目前,你有顶级

{
"id": 11583,
"Id": 11583,
"SerialNo": "12476127654",
"webix_kids": 1
},

以及您拥有的儿童数据

{
"id": 11583,
"Id": 11583,
"SerialNo": "12476127654",
"webix_kids": 1
},

两个项目共享相同的ID,因此treetable不会添加新项目。

答案 1 :(得分:0)

纠正JSON输出解决了我的问题。

对于父母;

{  
   "parent":"0",
   "data":[  
      {  
         "Id":11584,
         "id":11584,
         "SerialNo":"125235463",
         "webix_kids":1
      },
      {  
         "Id":11599,
         "id":11599,
         "SerialNo":"3444",
         "webix_kids":1
      }
   ]
}

对于孩子们;

{  
   "parent":11599,
   "data":[  
      {  
         "id":11583,
         "Id":11583,
         "SerialNo":"12476127654",
         "webix_kids":1
      },
      {  
         "id":11592,
         "Id":11592,
         "SerialNo":"151515",
         "webix_kids":1
      }
   ]
}