我尝试在树面板中显示文件系统。我用 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 不包含文件并且有一个箭头再次显示根目录(与我在评论中给出的图片相同)这是问题所在!