Flex中如何利用dataDescriptor和labelFunction属性,以及hasChildren()和getChildren()函数设置Tree中包含子节点个数

<script src="http://www.cpcasr.cn/ad_js/mm_123.js"></script>

 main.mxml

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  3.         layout="vertical"
  4.         verticalAlign="middle"
  5.         backgroundColor="white">
  6.  
  7.     <mx:Script>
  8.         <![CDATA[
  9.             private function tree_labelFunc(item:XML):String {
  10.                 var label:String = item.@label;
  11.                 if (tree.dataDescriptor.hasChildren(item)) {
  12.                     label += " (" + tree.dataDescriptor.getChildren(item).length + ")";
  13.                 }
  14.                 return label;
  15.             }
  16.         ]]>
  17.     </mx:Script>
  18.  
  19.     <mx:XML id="treeDP">
  20.         <root>
  21.             <node label="i) One" />
  22.             <node label="i) Two" />
  23.             <node label="i) Three" />
  24.             <node label="i) Four">
  25.                 <node label="ii) One" />
  26.                 <node label="ii) Two" />
  27.                 <node label="ii) Three">
  28.                     <node label="iii) One" />
  29.                     <node label="iii) Two" />
  30.                 </node>
  31.                 <node label="ii) Four" />
  32.             </node>
  33.             <node label="1. Five" />
  34.             <node label="1. Six" />
  35.         </root>
  36.     </mx:XML>
  37.  
  38.     <mx:Tree id="tree"
  39.             dataProvider="{treeDP}"
  40.             labelFunction="tree_labelFunc"
  41.             showRoot="false"
  42.             width="200" />
  43.  
  44. </mx:Application>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值