View Full Version : Strange Flex 3 Tree behaviour. A bug?
newflexquest
10-06-2008, 11:10 AM
Hello Everyone!
I use the flex 3 Tree component with a custom data descriptor.
The data-structure, which is processed by the data descriptor,
allows that one node may have several parent-nodes.
In this case the node is being shown in tree several times - once for every
parent-node.
The node itself may also have several children. (Some sort of a simplified Graph structure.)
This is rendered well, but when I open the node in the tree, the same node is automatically
opened by other parent-nodes. When i move the mouse-pointer over the nodes-children. they are not highlighted, and the respective children of some other parent-node are.
Any Ideas?
Thanks!
emogazine
10-06-2008, 04:42 PM
I got the same problem sometimes. it seems to be a bug in tree component. I need help in this also. Must wait for the upcoming flex 4
------------------------------------------------
www.emogazine.com - The best online text editor
dr_zeus
10-06-2008, 07:58 PM
If the exact same item appears in the Tree multiple times, the Tree will behave strangely just as you describe. I don't think they're planning to change this behavior. If you need the same data to appear in the Tree multiple places, ensure that you're using unique object instances.
The following code demonstrates basically what's happening (not exactly, but I hope it makes sense):
var obj1:Object = {label: 6, value: 4};
var obj2:Object = obj1;
trace(obj1 == obj2); //true
This is what you actually want:
var obj1:Object = {label: 6, value: 4};
var obj2:Object = {label: 6, value: 4};
trace(obj1 == obj2); //false
In the first code block, obj1 and obj2 point to the exact same object. In the second code block, they're two different objects that just happen to have the same variable values. You need to ensure that your data descriptor passes data to the Tree like the second code block rather than the first.
newflexquest
10-07-2008, 10:17 AM
Thats right, this behaviour takes plase only while using the same object instance several times in the tree.
The bad stuff is that i need exactly this :)
I cannot destroy data-integrity by duclicating nodes and all of their children, and their children and so on...
I made a debug in Tree, List and ListBase classes. The behaviour is as follows:
1. DisplayObjects are created for each appearance of the data-object in the tree.
2. On mouse-over event the display-object is taken to find corresponding data-object. Data-objects are stored in a map as key-value pairs, where the key is object-id and the value is the object itself.
Therefore it is clear: if an item must appear twice in the tree, related data-object may not be placed twice to the map (key violation). So at the end we have at the background only ONE data-object for all of the display-objects which represent duplication of the same item.
I hope the explanation is not heavy to read.
@newflexquest, I get your explanation but i don't see how it solves your problem...
If your data provider needs to maintain data integrity and hence not duplicate objects, how do you solve this problem? Can the tree be modified so that such situations can be handled?
In the first code block, obj1 and obj2 point to the exact same object. In the second code block, they're two different objects that just happen to have the same variable values. You need to ensure that your data descriptor passes data to the Tree like the second code block rather than the first.
@drzeus, won't this cause other complications, like the tree not always rendering up to date data as soon as the underlying dataprovider is updated?
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.