var root =new Ext.tree.AsyncTreeNode
({
id: "-100", //根节点id
text: "xx"
});
var panelmenu =new Ext.Panel({
width: 200,
nimSize: 200,
collapsible: true,
collapseMode: 'mini',
// items:extPanel
// margins:'0 0 0 5',
layout: 'accordion'
});
Ext.Ajax.request({
url: 'json1.ashx?tree1=1',
method: "GET",
success: function (response) {
var data = Ext.util.JSON.decode(response.responseText);
for (var i =0; i < data.lenght; i++) {//循环读取 data中的数据来生成panel和tree
// for (var j = 0; j < data.children.lenght; j++) {
//
// }
if (data.children.lenght >0) {
// tree.getRootNode().appendChild(data.children);
panelmenu.add(new Ext.Panel({
id: data[i].id,
title: data[i].text,
items: [new Ext.tree.TreePanel({
// renderTo: "show",
autoScroll: true,
containerScroll: true,
expanded: false,
root: root, //定位到根节点
animate: true, //开启动画效果
enableDD: false, //不允许子节点拖动
border: false, //没有边框
// layout: 'accordion',
rootVisible: true, //设为false将隐藏根节点
loader: new Ext.tree.TreeLoader({
data: data.children
// requestMethod: 'GET'
})
// tree.render();
})]
}));
}
else {
panelmenu.add(new Ext.Panel({
id: data[i].id,
title: data[i].text
}));
}
}
}
});