Search Flex Components Free

Custom Search

February 6, 2008

Removing leaf icons from the Flex Tree control




<mx:Style>

Tree {

defaultLeafIcon: ClassReference(null);

}

</mx:Style>


*************************************



<?xml version="1.0" encoding="utf-8"?>


<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"

layout="vertical"

verticalAlign="middle"

backgroundColor="white">



<mx:XML id="dp">

<mlb>

<league label="American League">

<division label="East">

<team label="Boston" />

<team label="New York" />

<team label="Toronto" />

<team label="Baltimore" />

<team label="Tampa Bay" />

</division>

<division label="Central">

<team label="Cleveland" />

<team label="Detroit" />

<team label="Minnesota" />

<team label="Chicago" />

<team label="Kansas City" />

</division>

<division label="West">

<team label="Los Angeles" />

<team label="Seattle" />

<team label="Oakland" />

<team label="Texas" />

</division>

</league>

</mlb>

</mx:XML>



<mx:Style>

Tree {

defaultLeafIcon: ClassReference(null);

}

</mx:Style>



<mx:Tree id="tree"

dataProvider="{dp.league}"

labelField="@label"

iconField="@icon"

showRoot="true"

width="320"

rowCount="9" />



</mx:Application>



************************************



If you want to set the defaultLeafIcon style to null in MXML, you could use the following snippet:


<mx:Tree id="tree"

dataProvider="{dp.league}"

defaultLeafIcon="{null}"

labelField="@label"

iconField="@icon"

showRoot="true"

width="320"

rowCount="9" />

Or, if you want to set the defaultLeafIcon style in ActionScript, you could use the following snippet:


<mx:Tree id="tree"

dataProvider="{dp.league}"

labelField="@label"

iconField="@icon"

showRoot="true"

width="320"

rowCount="9"

initialize="tree.setStyle('defaultLeafIcon', null);" />





Related Flex Tutorials