在Flex中让Tree绑定数据后自动展开树节点
2014-01-24 11:36
239 查看
用Flex/Flash做开发的同志们应该会使用 expandChildrenOf(item,true)方法来使用Tree组件在绑定数据后自动展开所有树型节点(不需要用户再自己点击展开节点,会方 便许多),而在Flex开发帮忙文档中很明确写道:
"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;//刷新
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);
}
注意:
http://blog.csdn.net/ask_rent/article/details/6422394
"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;//刷新
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);
}
注意:
http://blog.csdn.net/ask_rent/article/details/6422394
相关文章推荐
- Android布局的小窍门?
- Web布局连载——两栏固定布局(五)
- [备忘] 查看浏览器中flash swf的trace调试输出
- 我是运营,我没有假期
- flash 系统字体显示问题
- 比较完整简洁的Flash处理XML文档数据教程 上篇第1/3页
- Flash ActionScript 中按钮和电影剪辑的事件和方法
- flash 编程习惯 小结
- flash as2.0组件样式修改方法(直接改元件就行喽)
- FLASH自动判断域名然后转向等操作
- Flash简单加密 限制 Flash 在指定域名/网址中播放的方法
- 在网页中怎样给已发布的Flash添加链接的方法
- FLASH 多参数的URL地址(带&符号)
- DB2数据库的安装
- Flex 隐藏组件的属性
- Flex 如何得到itemRenderer里面的内容
- Flex字符串比较 还有Flex字符串操作
- Flex 透明效果,位于页面最底层
- Flex 非常实用的学习资料整理
- flex 控件的重要属性