Search Flex Components Free

Custom Search

February 6, 2008

Removing folder icons from the Flex Tree control





The following example shows how you can remove the folder icons from the Tree control in Flex so that only the disclosure (arrow) icons and leaf icons are visible.


The short answer, set the folderClosedIcon and folderOpenIcon styles to null using CSS, as shown in the following snippet:


<mx:Style>

Tree {

folderClosedIcon: ClassReference(null);

folderOpenIcon: ClassReference(null);

}

</mx:Style>

The long answer?

Full code after the jump.


View MXML


<?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 {

folderClosedIcon: ClassReference(null);

folderOpenIcon: ClassReference(null);

}

</mx:Style>



<mx:Tree id="TreeProject"

dataProvider="{dp.league}"

labelField="@label"

iconField="@icon"

showRoot="true"

width="320"

rowCount="9" />



</mx:Application>



Related Flex Tutorials