//Add this to the init function callLater(expandTOC); //Add this function private function expandTOC():void { toc.openItems = toc.dataProvider.source; for each(var item:TocMapLayerItem in toc.openItems) { if (item.isTopLevel()) toc.expandItem(item,true,true,true,null); } }
Guys,
Here is the solution.//Add this to the init function callLater(expandTOC); //Add this function private function expandTOC():void { toc.openItems = toc.dataProvider.source; for each(var item:TocMapLayerItem in toc.openItems) { if (item.isTopLevel()) toc.expandItem(item,true,true,true,null); } }
Guys,
Here is the solution.//Add this to the init function callLater(expandTOC); //Add this function private function expandTOC():void { toc.openItems = toc.dataProvider.source; for each(var item:TocMapLayerItem in toc.openItems) { if (item.isTopLevel()) toc.expandItem(item,true,true,true,null); } }
Leon,
Strange that you are having trouble with this... There must be a really slow map service in your map. The issue is that the Tree can not have the expand functions called before it is ready, meaning all the leafs are initialized. So if you have a very slow map service in your map then the expand function could be getting called before the tree is ready. You could try another callLater from the first callLater.
Robert
Leon,
Because you are using the TOC in a custom component, I am not sure when you are calling the expandTOC function, but it must be getting called to soon.
//Add this to the init function callLater(expandTOC); //Add this new function (make sure you don't add it inside of another function) private function expandTOC():void { if (expanded) { toc.openItems = toc.dataProvider.source; for each(var item:TocMapLayerItem in toc.openItems) { if (item.isTopLevel()) toc.expandItem(item,true,true,true,null); } } }