0
votes

I try to show in a Tree panel a Files System. I feed my tree with json data and it's work perfectly!

But when I have an empty folder, the tree folder (when it's deploy) show me the complete tree again. In my server I send a json file which doesn't have children properties.

This is my tree code

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) {
            }
        }
    });
});

and there is an example of my json code

[
{"cls":"first-level","expanded":"false","children":[
    {"cls":"first-level","expanded":"false","children":[
        {"leaf":"true","text":"..."},
        {"leaf":"true","text":"..."}
        ],"text":"..."}
    ],"text":"..."},
{"text":"..."}]

Anybody has an idea for help me?

Thanks!

David

EDIT:

an other example of my 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"}]

I explain with that -> BOBFOLDER1, BOBFOLDER2, BOBFOLDER3 contains files and don't have arrow (I can't deploy it and it's the good behaviour). But OTHERFOLDER1 don't contains files and have an arrow which display root again (same of my picture i give in comments) it's the problem!

2
question is not clear. where is the problem ? when you reload the page or when you click on an empty folder ?Sreenath S
When I click on the arrow of an empty folder, nothing must be visible, but my tree show the root again. This is an picture of my problem imageshack.us/photo/my-images/525/treek.jpgKalyh
I post an other example with a little explication. Thanks for your help.Kalyh
I found the solution ... I just add the same architecture ({"path":"...","cls":"first-level","expanded":"false","children":[],"text":"BOBFOLDER1"}) I add children:[] and the cls and it works perfectly ... Thanks for your helpKalyh
Can you post your own answer.. blog.stackoverflow.com/2011/07/…pd40

2 Answers

0
votes

the node named OTHER, is shown as a non-leaf node. put "leaf":"true" for the corresponding JSON data.

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"}]
0
votes

try setting putting loaded: true in all your nodes (or if you use a model config, create field in the model for "loaded" and default it to true.