Multiple Selected Items in a Tree Control in Flex.

To Access the multiple selected items in a Tree control we got to enable the multiple selection in the Tree control like below.


Then we can access the selectedItems of the Tree control with the property “selectedItems” like below code.

for(var i:int=0;i<tree.selectedItems.length;i++)

Here tree is the id of the Tree control and NAME is the attribute name of the dataProvider of the Tree control.Check the code for clearance.

Run Demo App.

Download Code Example.


4 Responses to Multiple Selected Items in a Tree Control in Flex.

  1. Mike says:

    Just passing by.Btw, your website have great content!

  2. Maria says:

    Hello! That’s great tree control! I’ve found something that seems to be an issue: when collapse a ‘folder’ which contains selected items, and then expand it again, the items are not selected anymore.
    May be, it is a feature?

    • bfitz says:

      I think it is a bug. If you have selected items and close the folder, it moves. The folder is selected, but only if it is the first folder closed and selected. Leave it selected, open another folder, ctrl+click to select another item, close the second folder and your selection is lost and the second folder is not selected. Now the really wierd part: if you have a folder with a lot of nodes, say 30, select some items, close the folder, open the folder and the items are still selected. Searching for a resolution and came across your post.

      • pj says:

        I had the same problem. The simplest solution that worked for me was disabling animation by forcing animate parameter on expandItem:

        override public function expandItem(item:Object, open:Boolean, animate:Boolean=false, dispatchEvent:Boolean=false, cause:Event=null):void {
        super.expandItem(item, open, false, dispatchEvent, cause);

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: