Ext tree菜单数据读取问题
同文件夹内,我在a.html里构建tree,部分代码:vartree=newExt.tree.TreePanel({id:'tree-mianban',title:'树'...
同文件夹内,我在a.html里构建tree,部分代码:
var tree = new Ext.tree.TreePanel({
id:'tree-mianban',
title:'树',
loader:treeLoader,
});
var treeLoader = new Ext.tree.TreeLoader({
dataUrl:'b.txt'
});
var root = new Ext.tree.AsyncTreeNode({
text:'根节点',
draggable:false,
id:'root',
});
jiezhe
tree.setRootNode(root);
tree.render(document.body);
root.expand();
在b.txt里写了json格式静态数据
[{
'text':'节点1',
'id':'01',
'children':[
{
'text':'子节点1','id':'001'
}
]
}]
打开页面后什么都不显示,也不报错,根节点出的来,但一直处于正在读取的状态?请问为什么 展开
var tree = new Ext.tree.TreePanel({
id:'tree-mianban',
title:'树',
loader:treeLoader,
});
var treeLoader = new Ext.tree.TreeLoader({
dataUrl:'b.txt'
});
var root = new Ext.tree.AsyncTreeNode({
text:'根节点',
draggable:false,
id:'root',
});
jiezhe
tree.setRootNode(root);
tree.render(document.body);
root.expand();
在b.txt里写了json格式静态数据
[{
'text':'节点1',
'id':'01',
'children':[
{
'text':'子节点1','id':'001'
}
]
}]
打开页面后什么都不显示,也不报错,根节点出的来,但一直处于正在读取的状态?请问为什么 展开
展开全部
<script type="text/javascript">
Ext.onReady(function(){
var tree=new Ext.tree.TreePanel({
width:250,
height:400,
loader:new Ext.tree.TreeLoader({dataUrl:'tree.ext'})
});
var root=new Ext.tree.AsyncTreeNode({text:'这是根'});
tree.setRootNode(root);
tree.render(document.body);
tree.render();
root.expand();
});
</script>
这样写就不会出错了。把treeLoader写在loader的后面就好了。
把你的这样已修改就没事了
<script type="text/javascript">
Ext.onReady(function(){
var tree = new Ext.tree.TreePanel({
id:'tree-mianban',
title:'树',
loader:new Ext.tree.TreeLoader({dataUrl:'tree.ext'})
});
var root = new Ext.tree.AsyncTreeNode({
text:'根节点',
draggable:false,
id:'root',
});
tree.setRootNode(root);
tree.render(document.body);
root.expand();
});
</script>
Ext.onReady(function(){
var tree=new Ext.tree.TreePanel({
width:250,
height:400,
loader:new Ext.tree.TreeLoader({dataUrl:'tree.ext'})
});
var root=new Ext.tree.AsyncTreeNode({text:'这是根'});
tree.setRootNode(root);
tree.render(document.body);
tree.render();
root.expand();
});
</script>
这样写就不会出错了。把treeLoader写在loader的后面就好了。
把你的这样已修改就没事了
<script type="text/javascript">
Ext.onReady(function(){
var tree = new Ext.tree.TreePanel({
id:'tree-mianban',
title:'树',
loader:new Ext.tree.TreeLoader({dataUrl:'tree.ext'})
});
var root = new Ext.tree.AsyncTreeNode({
text:'根节点',
draggable:false,
id:'root',
});
tree.setRootNode(root);
tree.render(document.body);
root.expand();
});
</script>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询