Flex中在Tree綁定數(shù)據(jù)后自動展開樹節(jié)點的方法
更新時間:2014年01月28日 17:14:01 作者:
使用Tree組件在綁定數(shù)據(jù)后自動展開所有樹型節(jié)點(不需要用戶再自己點擊展開節(jié)點,會方 便許多),接下來為大家介紹下具體的實現(xiàn)
用Flex/Flash做開發(fā)的同志們應(yīng)該會使用 expandChildrenOf(item,true)方法來使用Tree組件在綁定數(shù)據(jù)后自動展開所有樹型節(jié)點(不需要用戶再自己點擊展開節(jié)點,會方 便許多),而在Flex開發(fā)幫忙文檔中很明確寫道:
"If you set dataProvider and then immediately call expandChildrenOf() you may not see the correct behavior. You should either wait for the component to validate or call the validateNow() method. "
第一種:(已驗證)
//全部展開,初始選中第一項
treePlayList.dataProvider=results;//刷新Tree的全部節(jié)點展開 - royanxin - royanxin的博客
treePlayList.validateNow(); //驗證并更新此對象的屬性和布局,并重繪該對象(如果需要)。
treePlayList.selectedIndex=0;
treePlayList.expandChildrenOf(treePlayList.selectedItem,true);//全部展開
第二種:
setTimeout(IniExpand, 1000); //延時1秒
private function IniExpand():void {
TreeView1.selectedIndex=1;
TreeView1.expandItem(TreeView1.selectedItem,true);
}
第三種:
//全部展開,初始未選中任何選項
sysTree.validateNow();
for each(var item:XML in this.sysTree.dataProvider){
sysTree.expandChildrenOf(item,true);
}
注意:
"If you set dataProvider and then immediately call expandChildrenOf() you may not see the correct behavior. You should either wait for the component to validate or call the validateNow() method. "
第一種:(已驗證)
復制代碼 代碼如下:
//全部展開,初始選中第一項
treePlayList.dataProvider=results;//刷新Tree的全部節(jié)點展開 - royanxin - royanxin的博客
treePlayList.validateNow(); //驗證并更新此對象的屬性和布局,并重繪該對象(如果需要)。
treePlayList.selectedIndex=0;
treePlayList.expandChildrenOf(treePlayList.selectedItem,true);//全部展開
第二種:
復制代碼 代碼如下:
setTimeout(IniExpand, 1000); //延時1秒
private function IniExpand():void {
TreeView1.selectedIndex=1;
TreeView1.expandItem(TreeView1.selectedItem,true);
}
第三種:
復制代碼 代碼如下:
//全部展開,初始未選中任何選項
sysTree.validateNow();
for each(var item:XML in this.sysTree.dataProvider){
sysTree.expandChildrenOf(item,true);
}
注意:
相關(guān)文章
flex中validateall()方法實現(xiàn)多Item驗證且結(jié)果統(tǒng)一提示
在本文將為大家介紹下flex中validateall()方法如何實現(xiàn)多Item驗證且結(jié)果統(tǒng)一提示,具體如下,感興趣的朋友可以參考下2013-09-09
flex4.5中CSS選擇器的應(yīng)用小結(jié)
與HTML相似,F(xiàn)lex允許在MXML標簽中通過CSS樣式來設(shè)置組件的外觀。到flex4.5后已經(jīng)基本上支持了HTML中的所有CSS的應(yīng)用方式,這里主要來列舉下flex4.5中CSS選擇器的使用方法2013-04-04
Flex 基于數(shù)據(jù)源的Menu Tree實現(xiàn)代碼
由外部參數(shù)flashvars指定數(shù)據(jù)源的文件位置或render鏈接,在源數(shù)據(jù)上加href和target屬性來控制打開窗口,可自定義父節(jié)點和子節(jié)點圖標,不設(shè)置采用系統(tǒng)默認,感興趣的你可以了解下啊,或許對你有所幫助2013-01-01
Flex中如何動態(tài)生成DataGrid以及動態(tài)生成表頭
因某些需要,DataGrid及其表頭需要動態(tài)生成,網(wǎng)上的解決方案打多籠統(tǒng),下面有個不錯的解決方法,感興趣的朋友可以參考下2013-10-10

