Hi guys,
I'm going to find the index of an item from tree list, then use that
index as .selectedIndex of tree, to highlight that item. The
dataProvider I used for the tree like this:
this._source = <list>
<node label="A" data="a">
<node label="A1" data="a1"/>
<node label="A2" data="a2"/>
<node label="A3" data="a3">
<node label="A4" data="a4"/>
</node>
</node>
<node label="B" data="b">
<node label="B1" data="b1">
</node>
</node>
</list>;
[Bindable]
public var sourceTree:XMLList;
<mx:Tree id="list" dataProvider="{this.sourceTree}" />
public function reselectItemFromData(data:String):void
{
var treeList:XMLList =this.list.dataProvider as XMLList;
//TODO: find the index here.
}
So I want to reselect an item with @data value, i.e.
reselectItemFromData('b'). Should I go through the _source XML and find
the index of 'B' item and use that integer as .selectedIndex(not quite
sure correct or not), or there's a better way on this?
Any help appreciated.
Thanks,
George