tags:

views:

234

answers:

1

I have an array of items that should be selected in my tree control. As you can see from my code below, I bind this array to the selectedItems property of the tree. If the selectedItems are toward the top of the tree, then the selection works just fine. However, if the items are toward the bottom of the tree, Flex seems to "ignore" my items (selects nothing). Am I missing something? Perhaps I'm going about this the wrong way?

Thanks for your help!

public function expand_tree(selectedItems:Array):Array {
        category_tree.validateNow();
        for each (var item:* in selectedItems) {
            category_tree.expandItem(item, true);
        }
        return selectedItems;
      }

<mx:Tree
      width="280"
      id="category_tree"
      allowMultipleSelection="true"
      dataProvider="{pm.categories}"
      labelField="name"
      selectedItems="{expand_tree(pm.selectedCategoryItems)}"
      change="pm.updatePageCategories(category_tree.selectedItems)"/>
A: 

It appears that the problem was that some of the tree children were not open. I now loop through my selected items and open those tree branches first.

erikcw