AabinGunz
AabinGunz

Reputation: 12347

Flex 3 List dataprovider based on matching attribute

I have some xml, I want to give it to a List dataprovider, but based on an attribute match.

My Xml

<components>
<rows name="general">
    <objects name="Start" image16="startflag16" image32="startflag32" class="someclass">
        <property>To</property>
        <property>Subject</property>
        <property>Content</property>
        <property>Attachments</property>
    </objects>
    <objects name="Stop" image16="endflag16" image32="endflag32" class="someclass">
        <property>Id</property>
        <property>Workflow Name</property>
    </objects>
    <objects name="Command" image16="command16" image32="command32" class="someclass">
        <property>Id</property>
        <property>Command</property>
        <property>Working Dir</property>
    </objects>
</rows>
<rows name="int">
</rows>
<rows name="data">
</rows>
</components>

My code

<mx:List id="listView" textIndent="5" verticalScrollPolicy="auto"
         dragEnabled="true" labelField="name" iconField="image" height="100%" width="140">
</mx:List>

And I am trying to do something like below, If I remove (@name=="general") from below line it gives me all property

listView.dataProvider=list_components.rows(@name=="general").objects.property;

But it gives me error, so basically I want to get all property based on rows attribute name matching general

Upvotes: 0

Views: 175

Answers (1)

Amy Blankenship
Amy Blankenship

Reputation: 6961

Use an XMLListCollection and either use e4x to filter the XMLList you use as the source or use a filterFunction on the XMLListCollection.

Upvotes: 1

Related Questions