PDA

View Full Version : Tree displays recursive values



shu_wang
12 Nov 2014, 2:22 PM
Hello, I am new to ExtJS and there is a bug that I need to fix. Our application has a tree like:
Node 1
Node 2

When all nodes are expanded, it looks like:
Node 1
Unit 1

Component 1

Component 2

Unit 2

Component 3
Node 2
Unit 3

Component 4


We use NodeTreeStore, UnitTreeStore and ComponentTreeStore. They all use proxy URL to get data in XML format.

In the tree, a listener beforeitemexpand is defined to append childNodes based on the node type. For example:
if (node.data.type == 'node') {
var Unitlength = UnitStore.getRootNode().childNodes.length;
for (var j=0; j<=(Unitlength -1); j++){
if (node.get('name') == UnitStore.getRootNode().getChildAt(j).get('node')){
node.appendChild(UnitStore.getRootNode().getChildAt(j));
Unitlength = Unitlength-1;
j = j-1;
}
}
}


Now the problem is when the tree is loaded, sometimes not all the nodes are loaded. If I expand a node that is not loaded, it takes a while, then displays recursive values:
Node 1
Node 1

Node 2
Node 2


How can I get around with this problem? Thank you!

slemmon
13 Nov 2014, 10:03 PM
I'm guessing you've got some nodes in the tree with duplicate IDs. You'll need to make sure all IDs in the tree are unique.

shu_wang
14 Nov 2014, 8:29 AM
Thank you for your response. I checked node.id on the tree, they are all different. node.getId() is undefined. Should I define this id for the nodes?

slemmon
14 Nov 2014, 9:07 AM
I'm not sure.
It may help to see this in action.
Can you post a simple test case demonstrating the issue to https://fiddle.sencha.com?