You might need a custom ITreeDataDescriptor implementation.

On 2/26/10 11:13 PM, "Patil Yogesh" <[email protected]> wrote:







I am trying to construct dataprovider from two different sources in Tree
control. I am able to construct it but when I perform drag and drop
operation on nodes in tree, it gives a weird behavior.

Following is the prototype for that:

<?xml version="1.0" encoding="utf-8"?>
<s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009";
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo"
initialize="initTree(event)">

<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.FlexEvent;

[Bindable]
private var treeData : ArrayCollection = new ArrayCollection();

[Bindable]
private var testData : ArrayCollection;

[Bindable]
private var testData2 : ArrayCollection;

protected function initTree(event:FlexEvent):void
{
testData = new ArrayCollection([{label:"One"}, {label:"Two"},
{label:"Three"}]);
testData2 = new ArrayCollection([{label:"One"}, {label:"Two"},
{label:"Three"}]);
createDataProvider();
treeControl.dataProvider = treeData;
}

private function createDataProvider() : void {
for(var i : int = 0; i < testData.length; i++) {
var label : String = testData[i].label;

var list : ArrayCollection = new ArrayCollection();

list.list = testData2.list;

var filter : Function = function(obj : Object) : Boolean {
if(obj.label == label) return true;
return false;
};

list.filterFunction = filter;
list.refresh();
treeData.addItem({label:testData[i].label, children:list});
}
}
]]>
</fx:Script>
<mx:VBox width="100%">
<mx:Tree id="treeControl" width="100%" right="-1" left="-1" bottom="-1"
top="44" borderAlpha="0.75"
 dragEnabled="true" dropEnabled="true"/>
</mx:VBox>

</s:Application>

-----
--
Regards,
Yogesh Patil.

--
Alex Harui
Flex SDK Team
Adobe System, Inc.
http://blogs.adobe.com/aharui

Reply via email to