问题:ExtJS 4.2 树形结构请求后台数据无法展示子节点,而是没点击一次请求一次数据,无限请求加载所有的父节点元素
解决办法:首先获取到后台数据,然后重写(重新创建)store,store里面需要加上root:{expanded:true,children:data(后台获取的数据)},然后再创建tree;
试过了下面这种方法会报错
new Ext.tree.TreePanel({
animate: false,
autoScroll: true,
containerScroll: true,
border: false,
height: 300,
useArrows: true,
animCollapse: false,
root:{
nodeType: 'async',
id: 'root',
expanded: false
},
loader:new Ext.tree.TreeLoader({
url: 'XXX',
baseParams:{
root: 'productLine'
}
}),
rootVisible: false
})
最后的解决方法代码贴下面:
Ext.Ajax.request({
url: url,//请求durl
method: "GET",
// jsonData: paramObj,
autoLoad: false,
ContentType: 'application/json;charset=utf-8',