我尝试在Tree面板中显示一个文件系统。 我用json数据喂我的树,它的工作非常完美!
但是当我有一个空文件夹时,树文件夹(当它部署时)会再次显示完整的树。 在我的服务器中,我发送了一个没有子属性的json文件。
这是我的树代码
Ext.onReady(function () {
var treeStore = Ext.create('Ext.data.TreeStore', {
proxy: {
type: 'ajax',
url: '/File/Tree'
},
root: {
text: 'Files root',
id: 'root',
expanded: true
}
});
var treeUp = Ext.create('Ext.tree.Panel', {
id: 'TreeFileSystem',
title: 'TEST',
useArrows: true,
store: treeStore,
rootVisible: false,
renderTo: 'Tree',
height: 350,
listeners: {
itemClick: function (view, record) {
}
}
});
});
并且有一个我的json代码的例子
[
{"cls":"first-level","expanded":"false","children":[
{"cls":"first-level","expanded":"false","children":[
{"leaf":"true","text":"..."},
{"leaf":"true","text":"..."}
],"text":"..."}
],"text":"..."},
{"text":"..."}]
有人有想法帮助我吗?
谢谢!
大卫
编辑:
我的JSON的另一个例子
[
{"path":"...","cls":"first-level","expanded":"false","children":[
{"path":"...","cls":"first-level","expanded":"false","children":[
{"path":"...","cls":"first-level","expanded":"false","children":[],"text":"BOBFOLDER1"},
{"path":"...","cls":"first-level","expanded":"false","children":[],"text":"BOBFOLDER2"},
{"path":"...","cls":"first-level","expanded":"false","children":[],"text":"BOBFOLDER3"}
],"text":"BOB"},
{"path":"...","cls":"first-level","expanded":"false","children":[
{"path":"...","expanded":"false","text":"OTHERFOLDER1"}
],"text":"OTHER"}
],"text":"20508322"}]
我解释说 - > BOBFOLDER1,BOBFOLDER2,BOBFOLDER3包含文件而且没有箭头(我无法部署它并且它是良好的行为)。 但是OTHERFOLDER1不包含文件并且有一个箭头再次显示root(我在评论中给出了相同的图片)这就是问题!
答案 0 :(得分:0)
名为OTHER
的节点显示为非叶节点。将"leaf":"true"
放入相应的JSON数据。
即
[
{"cls":"first-level","expanded":"false","children":[
{"cls":"first-level","expanded":"false","children":[
{"leaf":"true","text":"..."},
{"leaf":"true","text":"..."}
],"text":"..."}
],"text":"BOB"},
{"text":"OTHER","leaf":"true"}]
答案 1 :(得分:0)
尝试在所有节点中设置put loaded:true(或者如果使用模型配置,则在模型中为“loaded”创建字段并将其默认为true。