Tips&Tricks: Flex expand AdvancedDataGrid tree column on load
Posted by Jai on August 18, 2009
Use displayExpandItems=”true” to expand all the elements of the tree component items on initial load.
<mx:AdvancedDataGrid groupItemRenderer="com.test.CheckBoxTreeRenderer"
id="dataGrid"
dataProvider="{appModel.list}"
width="90%"
height="100%"
displayItemsExpanded="true">
<mx:columns>
<mx:AdvancedDataGridColumn id="labelColumn" dataField="label" headerText="Data"/>
</mx:columns>
</mx:AdvancedDataGrid>
The problem with expandAll() to be called on creation is that the model may not be updated at that moment.


Sasha Dzeletovic said
Thanks Jai!
I had the exact same problem with expandAll(). This is an efficient shortcut.
Robertus said
Nice article. I have problem in expanding tree on load. Thanks
Chuck said
Thanks this is very helpful
Oswaldo said
Thanks! Simple but effective
Hichem Ben Abdallah said
Hi Jai,
You can use the method “callLater” to guarantee that all nodes will be expanded at the right moment.
Ahmed Malik said
Hey Jaibeer
Thank you for the great info. This helps expanding but later collapseAll() doesn’t work at all. Any idea how that can be made to work too?
Best regards,
Ahmed Malik.
Ahmed Malik said
Got it… you need to have
displayItemsExpanded=”false”;
before… collapseAll();
Thanks.
Best regards,
Ahmed.