PDA

View Full Version : Tree empty folder show root node



dadaking
14 Sep 2012, 6:54 AM
Hello,

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.

Anybody has an idea for help me?

Thanks!

David

scottmartin
16 Sep 2012, 6:01 PM
Does it help to call tree.removeAll()?

Scott.

dadaking
16 Sep 2012, 10:43 PM
Thanks for your answer.

But I don't know how use it. There is my code for the tree:



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":"..."}
]


When I look the console of firebug, I can see, when I open the empty folder, the tree call again the store withouth attribute.38728
And there is a screenshot of the tree.
38729

dadaking
19 Sep 2012, 12:29 AM
Nobody have an idea?

EDIT: I found the solution, I build my JSON with this achitecture :




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

The cls and children:[] solve the problem.