• [Flex] 组件Tree系列 —— 将数组作为dataProvider


    mxml:

    <?xml version="1.0" encoding="utf-8"?>
    
    <!--功能描述:将数组作为dataProvider-->
    
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                   xmlns:s="library://ns.adobe.com/flex/spark" 
                   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
        
        <fx:Script>
            <![CDATA[
                protected function tree_labelFunction(item:Object):String
                {
                    var num:String = "";
                    if (tree.dataDescriptor.hasChildren(item)) {
                        num = " (" + item.children.length + ")";
                    }
                    return item.label + num;
                }
            ]]>
        </fx:Script>
        
        <fx:Declarations>
            <!-- 将非可视元素(例如服务、值对象)放在此处 -->
            <fx:Array id="data">
                <fx:Object label="周星驰">
                    <fx:children>
                        <fx:Object label="1988">
                            <fx:children>
                                <fx:Object label="《霹雳先锋》香港票房8916612" />
                                <fx:Object label="《捕风汉子》香港票房3149395" />
                                <fx:Object label="《最佳女婿》香港票房5807710" />
                            </fx:children>
                        </fx:Object>
                        <fx:Object label="1989">
                            <fx:children>
                                <fx:Object label="《龙在天涯》香港票房6809853 " />
                                <fx:Object label="《义胆群英》香港票房7913329" />
                                <fx:Object label="《流氓差婆》香港票房5624622 " />
                                <fx:Object label="《风雨同路》香港票房9335299 " />
                                
                            </fx:children>
                        </fx:Object>
                    </fx:children>
                </fx:Object>
                <fx:Object label="李连杰">
                    <fx:children>
                        <fx:Object label="1992">
                            <fx:children>
                                <fx:Object label="笑傲江湖之东方不败(1992)" />
                                <fx:Object label="黄飞鸿之二男儿当自强(1992)" />
                                <fx:Object label="黄飞鸿之三狮王争霸(1992)" />
                            </fx:children>
                        </fx:Object>
                        <fx:Object label="1993">
                            <fx:children>
                                <fx:Object label="方世玉Ⅱ万夫莫敌(1993) " />
                                <fx:Object label="倚天屠龙记之魔教教主(1993)" />
                                <fx:Object label="黄飞鸿之铁鸡斗蜈蚣(1993) " />
                                <fx:Object label="太极张三丰(1993) " />
                                
                            </fx:children>
                        </fx:Object>
                        <fx:Object label="1993">
                            <fx:children>
                                <fx:Object label="新少林五祖(1994) " />
                                <fx:Object label="精武英雄(1994)" />
                                <fx:Object label="中南海保镖(1994)  " />
                                <fx:Object label="给爸爸的信(1995) " />
                            </fx:children>
                        </fx:Object>
                    </fx:children>
                </fx:Object>
            </fx:Array>
        </fx:Declarations>
        
        <mx:Tree id="tree" dataProvider="{data}" labelField="label"  width="320" labelFunction="tree_labelFunction"/>
    </s:Application>
  • 相关阅读:
    discuz $_G变量
    php & 引用
    discuz模板引擎
    nginx正则表达式
    linux系统安装 dig和nslookup命令
    linux中的各种$号 位置参数变量
    memcache图形管理工具
    mysql 注入问题
    pycharm 连接mysql失败
    Bootstrap 常用网站
  • 原文地址:https://www.cnblogs.com/frost-yen/p/4308820.html
Copyright © 2020-2023  润新知