• [Flex] 组件Tree系列 —— 运用LabelFunction hasChildren getChildren设置Tree包含节点个数


    mxml:

     1 <?xml version="1.0" encoding="utf-8"?>
     2 
     3 <!--功能描述:运用LabelFunction hasChildren getChildren设置Tree包含节点个数-->
     4 
     5 <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
     6                xmlns:s="library://ns.adobe.com/flex/spark" 
     7                xmlns:mx="library://ns.adobe.com/flex/mx" width="1080" height="1920" addedToStage="application1_addedToStageHandler(event)" resize="application1_resizeHandler(event)">
     8     
     9     <fx:Script>
    10         <![CDATA[
    11             import mx.events.ResizeEvent;
    12             
    13             protected function tree_labelFunction(item:Object):String
    14             {
    15                 var label:String = item.@label;
    16                 if (tree.dataDescriptor.hasChildren(item)) {
    17                     label += " (" + tree.dataDescriptor.getChildren(item).length + ")";
    18                 }
    19                 
    20                 return label;
    21                 
    22             }
    23             
    24             protected function application1_addedToStageHandler(event:Event):void
    25             {
    26                 trace(stage.stageWidth,stage.width,stage.stageHeight,stage.height);
    27                 this.width = 1080;
    28                 this.height = 1920;
    29                 trace(stage.stageWidth,stage.width,stage.stageHeight,stage.height);
    30                 trace(this.width,this.height);
    31             }
    32             
    33             protected function application1_resizeHandler(event:ResizeEvent):void
    34             {
    35                 //this.width = 1080;
    36                 //this.height = 1920;
    37                 trace(this.width,this.height);
    38             }
    39             
    40         ]]>
    41     </fx:Script>
    42     
    43     <fx:Declarations>
    44         <!-- 将非可视元素(例如服务、值对象)放在此处 -->
    45         <fx:XML id="data" xmlns="">
    46             <data>
    47                 <actor label="周星驰" clickEnabled="false">
    48                     <year label="1988">
    49                         <item label="《霹雳先锋》香港票房8916612 " clickEnabled="false"/>
    50                         <item label="《捕风汉子》香港票房3149395 " />
    51                         <item label="《最佳女婿》香港票房5807710 " />
    52                     </year>
    53                     <year label="1989">
    54                         <item label="《龙在天涯》香港票房6809853 " clickEnabled="false"/>
    55                         <item label="《义胆群英》香港票房7913329 " />
    56                         <item label="《流氓差婆》香港票房5624622 " />
    57                         <item label="《风雨同路》香港票房9335299 " />
    58                     </year>
    59                     <year label="1990 ">
    60                         <item label="《望夫成龙》香港票房13703364 " />
    61                         <item label="《咖喱辣椒》香港票房15777856 " />
    62                         <item label="《小偷阿星》香港票房7968106 " />
    63                         <item label="《师兄撞鬼》香港票房12128944 " clickEnabled="false"/>
    64                         <item label="《赌圣》香港票房41326156 " />
    65                         <item label="《无敌幸运星》香港票房18799869" />
    66                         <item label="《江湖最后一个大佬》香港票房5495811 " />
    67                     </year>
    68                 </actor>
    69                 <actor label="李连杰">
    70                     <year label="1992">
    71                         <item label="笑傲江湖之东方不败(1992)" clickEnabled="false" />
    72                         <item label="黄飞鸿之二男儿当自强(1992)" />
    73                         <item label="黄飞鸿之三狮王争霸(1992)" />
    74                     </year>
    75                     <year label="1993">
    76                         <item label="方世玉Ⅱ万夫莫敌(1993)" />
    77                         <item label="倚天屠龙记之魔教教主(1993)" />
    78                         <item label="黄飞鸿之铁鸡斗蜈蚣(1993)" />
    79                         <item label="太极张三丰(1993)" />
    80                     </year>
    81                     <year label="1994">
    82                         <item label="新少林五祖(1994)" />
    83                         <item label="精武英雄(1994)" />
    84                         <item label="中南海保镖(1994) " />
    85                         <item label="给爸爸的信(1995" />
    86                     </year>
    87                     <year label="1995">
    88                         <item label="鼠胆龙威(1995)" />
    89                         <item label="给爸爸的信(1995" />
    90                     </year>
    91                 </actor>
    92             </data>
    93         </fx:XML>
    94     </fx:Declarations>
    95     <mx:Tree id="tree" dataProvider="{data}" labelField="@label" showRoot="false" width="320" labelFunction="tree_labelFunction"/>
    96 </s:Application>
  • 相关阅读:
    边走边学Nodejs (基础入门篇)
    Android应用打包安装过程具体解释
    ubuntu与centos安装软件的不同点总结
    你好,C++(12)怎样管理多个类型同样性质同样的数据?3.6 数组
    oracle暂时表空间 ORA-01652:无法通过16(在表空间XXX中)扩展 temp 字段
    iOS中sqlite3操作
    sparkSQL1.1入门之二:sparkSQL执行架构
    [NHibernate]视图处理
    [NHibernate]立即加载
    [NHibernate]延迟加载
  • 原文地址:https://www.cnblogs.com/frost-yen/p/4308824.html
Copyright © 2020-2023  润新知