0

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

4

2 回答 2

0

尝试在所有节点中设置 puts loaded: true (或者如果您使用模型配置,请在模型中为“已加载”创建字段并将其默认为 true。

于 2012-09-19T17:35:11.720 回答
0

名为 的节点OTHER显示为非叶节点。put"leaf":"true"对应的 JSON 数据。

IE

[
{"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"}]
于 2012-09-19T13:07:54.860 回答