Thanks Tracy,

Yes I know. In my case the Tree data supposed to be dynamic, so when 
dataProvider changed, I have to find the selectedItem with the same 
@data and highlight that one.

I'll try to figure out how can I get the right index.

George

Tracy Spratt wrote:
> With Tree, the index is not very useful because index is linear, but the
> Tree data is hierarchical.
>
> Instead, use an e4x expression to find the node. 
>
> Tracy
>
> ________________________________
>
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of George
> Sent: Wednesday, November 07, 2007 12:44 PM
> To: [email protected]
> Subject: [flexcoders] How could I get the index of tree when use XMLList
> as dataProvider?
>
>  
>
> 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
>   

Reply via email to