码迷,mamicode.com
首页 > Web开发 > 详细

ExtJs动态生成treepanel的Json格式

时间:2015-07-18 10:44:45      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:

 

在节点中加上"checked"属性,会自动生成checkbox。

获取选中节点

var nodeArray = "";

var nodesObj = mytree.getChecked();

var i;var length=nodesObj .length;
for (i = 0; i < length; i++) {
nodeArray += nodesObj[i].id + ‘,‘;     //允许多选的情况。如果不允许多选,就直接nodesObj[i].id 
}

nodeArray = nodeArray.substring(0, nodeArray.length - 1);  

Json格式如下:

[{
"text": "To Do",
"cls": "folder",
"expanded": true,
"children": [{
"text": "Go jogging",
"leaf": true,
"checked": true
},{
"text": "Take a nap",
"leaf": true,
"checked": false
},{
"text": "Climb Everest",
"leaf": true,
"checked": false
}]
},{
"text": "Grocery List",
"cls": "folder",
"children": [{
"text": "Bananas",
"leaf": true,
"checked": false
},{
"text": "Milk",
"leaf": true,
"checked": false
},{
"text": "Cereal",
"leaf": true,
"checked": false
},{
"text": "Energy foods",
"cls": "folder",
"children": [{
"text": "Coffee",
"leaf": true,
"checked": false
},{
"text": "Red Bull",
"leaf": true,
"checked": false
}]
}]
},{
"text": "Remodel Project",
"cls": "folder",
"children": [{
"text": "Finish the budget",
"leaf": true,
"checked": false
},{
"text": "Call contractors",
"leaf": true,
"checked": false
},{
"text": "Choose design",
"leaf": true,
"checked": false
}]
}]

ExtJs动态生成treepanel的Json格式

标签:

原文地址:http://www.cnblogs.com/tdws/p/4656246.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!