extjs treepanel的应用,该如何解决
extjs treepanel的应用
小弟extjs新手,当前正在摸索中 extjs4.2.0 +C#
我在js中,写了一个布局函数,部分代码如下:
已经运行成功了,这个里边有一个'trpl'的treepanel,
下边是另外一个函数
此函数中json是json字符串,已经传入成功了。object转换的对象,其实就是个list<model>,
有id,name,shouname,parentid等等字段。
问题是,我想循环这个object[i]对象组,每一个对象成员声明一个treenode,然后加到
treepanel下,摸索了一天了,没有找到合适的方法,比如我的extjs没有ext.tree.treenode,
网上的代码有的,我该怎么声明树节点呢,另外,用ext.getCmp('trpl')找到了treepanel,
怎么把创建好的treenode加上去呢
------解决思路----------------------
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
region: 'west',
collapsible: true,
title: '导航',
xtype: 'panel',
width: 200,
autoScroll: true,
items: [{
xtype: 'treepanel',
border: 0,
rootVisible: false,
expanded: true,
root: {
title: '系统'
},
id: 'trpl',
items: [{
new ext.tree.treenode{
......
}
}]
}]
------解决思路----------------------
大概思路就是把root设定好 然后替换根节点
小弟extjs新手,当前正在摸索中 extjs4.2.0 +C#
我在js中,写了一个布局函数,部分代码如下:
{
region: 'west',
collapsible: true,
title: '导航',
xtype: 'panel',
width: 200,
autoScroll: true,
items: [{
xtype: 'treepanel',
border: 0,
rootVisible: false,
expanded: true,
root: {
title: '系统'
},
id: 'trpl'
}]
已经运行成功了,这个里边有一个'trpl'的treepanel,
下边是另外一个函数
function DecodeJson(json) {
var object = eval('(' + json.responseText + ')');
}
此函数中json是json字符串,已经传入成功了。object转换的对象,其实就是个list<model>,
有id,name,shouname,parentid等等字段。
问题是,我想循环这个object[i]对象组,每一个对象成员声明一个treenode,然后加到
treepanel下,摸索了一天了,没有找到合适的方法,比如我的extjs没有ext.tree.treenode,
网上的代码有的,我该怎么声明树节点呢,另外,用ext.getCmp('trpl')找到了treepanel,
怎么把创建好的treenode加上去呢
------解决思路----------------------
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
region: 'west',
collapsible: true,
title: '导航',
xtype: 'panel',
width: 200,
autoScroll: true,
items: [{
xtype: 'treepanel',
border: 0,
rootVisible: false,
expanded: true,
root: {
title: '系统'
},
id: 'trpl',
items: [{
new ext.tree.treenode{
......
}
}]
}]
------解决思路----------------------
var root = {
title: '系统',
expanded: true,
children:[]
};
for(var i=0;i<object.length;i++){
root.children.push({ //
id=object[i].id,
name=object[i].name,
shouname=object[i].shouname,
parentid=object[i].parentid,
leaf: true
});
tree.setRootNode(root); //tree为你要操作的树
}
大概思路就是把root设定好 然后替换根节点