最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
extjs 3.31 TreeGrid实现:静态页面加载json到TreeGrid里面
时间:2026-06-12 09:56:54 编辑:袖梨 来源:一聚教程网

复制代码 代码如下:
var root = new Ext.tree.TreeNode({
text: '根节点',
expanded: true
});
tree.setRootNode(root);
var nodes = {};
nodes.children = mydata;/*TreeGrid的json数据[{……},{……}]*/
function appendChild(node, o) {
if (o.children != null && o.children.length > 0) {
for (var a = 0; a < o.children.length; a++) {
var n = new Ext.tree.TreeNode({
task:o.children[a].task,
duration:o.children[a].duration,
user:o.children[a].user,
iconCls:o.children[a].iconCls
});
node.appendChild(n);
appendChild(n, o.children[a]);
}
}
}
appendChild(root, nodes);
看源码我们知道 TreeGrid 继承于 TreePanel
所以 root 才是数据源而不是 store,
根据加载json数据到树的原理,同理我们可以这样加载json数据到 treeGrid,而不再为dataUrl: 'treegrid-data.json'这样的加载方式而烦恼了,是不是很简单呢?
相关文章
- CanopyOps:AI Agent 工具实践指南 10-07
- newbie-dev-buddy:实践指南 10-07
- notabene:实践指南 10-07
- cwi-learn:AI Agent 工具实践指南 10-07
- NinFenz:AI Agent 工具实践指南 10-07
- SpaceAssistant:AI Agent 工具实践指南 10-07