PDA

View Full Version : ExtJS 3.0 TreePanel AsyncNode Loading JSon data infinite times at root node



palash
7 Sep 2009, 9:39 PM
Hi
I have this issue with Ext.tree.TreePanel loading JSON data from a servlet using Ext.tree.TreeLoader.
Here is my javascript to create tree:
***********************************
var treePanel = new Ext.tree.TreePanel( {
id : 'tree-panel1',
region : 'center',
margins : '2 2 0 2',
autoScroll : true,
rootVisible : true,
singleExpand : true,
loader : new Ext.tree.TreeLoader( {
method: 'Get',
dataUrl : '../catalog?'+query,
}),
root : new Ext.tree.AsyncTreeNode()
});
treePanel.expandAll();
treePanel.getSelectionModel().on('selectionchange', chageMyTree);
***************************************************
The servlet ("catalog") is returning data like this:
[{"text":"wqqwqw111","nodetype":"catalog","iconCls":"tree-template-icon","description":"aaaa","id":"1"}]

However, it creates the node infinite times for some reason. It keeps on creating infinite number of nodes once the page loads.
Do you think I m missing any configuration option.

Condor
7 Sep 2009, 11:25 PM
Yes, your node attributes should contain leaf:true.

palash
8 Sep 2009, 2:40 AM
Hi
I have tried returning leaf:true as a node attribute, it still creates infinite nodes.
I tried returning following JSON string:
[{"text":"wqqwqw111","description":"aaaa","leaf":true,"url":"catalog.html?a=t&i=1","id":"1","edit":false}] .

palash
8 Sep 2009, 2:59 AM
You are right, it needed leaf:true. My mistake was while creating JSON object at Java side.
Once I added it, I don't get infinite loop while rendering nodes.
Thanks a lot.