Flex3 AdvancedDataGrid 树形结构展示数据

代码如下:

<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" 
	xmlns:flexlib="http://code.google.com/p/flexlib/"
	width="100%"
	height="100%"
	creationComplete="handleCreationComplete()">
	<mx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.controls.Alert;
            
            [Bindable]
            private var dataProviderArrayCollection:ArrayCollection=new ArrayCollection([
            	{"name":"事件1","code":"1",
            	"children":new ArrayCollection([
            		{"name":"情景1","code":"情景1"},
            		{"name":"情景2","code":"情景2",
            		"children":new ArrayCollection([
            			{"name":"3情景1","code":"3情景1"},
            			{"name":"3情景2","code":"3情景2"}])}])},
            	{"name":"事件2","code":"2","children":new ArrayCollection([
            		{"name":"情景1","code":"情景1"},
            		{"name":"情景2","code":"情景2"}])}]);
            
            private function handleCreationComplete():void
            {
                //var obj:Object={"name": "事件3", "code": "3"};
                //obj.children=new ArrayCollection([{"name": "情景1", "flag": "true"}, {"name": "情景2", "flag": "true"}]);
                //dataProviderArrayCollection.addItem(obj);
                dataProviderArrayCollection.refresh();
            }
        ]]>
    </mx:Script>
    <!--
    <mx:HBox width="100%" height="100%">
        <flexlib:TreeGrid 
            styleName="dataGrid2"
            showRoot="true"
            width="100%" height="100%" 
            dataProvider="{dataProviderArrayCollection}"
            paddingLeft="25"
            verticalTrunks="none"
             >
        
            <flexlib:columns>
                <flexlib:TreeGridColumn headerText="名称" dataField="name" />
                <mx:DataGridColumn dataField="预报" />
                <mx:DataGridColumn headerText="操作">
                    <mx:itemRenderer>
                        <mx:Component>
                            <mx:HBox width="100%" horizontalAlign="center" horizontalGap="10">
                                 <mx:Image toolTip="模拟演进"  click="outerDocument.clickHandler(data)" visible="{data.flag}"   buttonMode="true"  useHandCursor="true" />
                            </mx:HBox>
                        </mx:Component>
                    </mx:itemRenderer>
                </mx:DataGridColumn>
            </flexlib:columns>
            
        </flexlib:TreeGrid>
    </mx:HBox>
    -->
    <mx:AdvancedDataGrid id="myADG" width="100%" height="100%" color="0x323232">  
   <mx:dataProvider>
    <mx:HierarchicalData  id="hd" source="{dataProviderArrayCollection}" childrenField="children"/>
   </mx:dataProvider>        
   <mx:columns>
    <mx:AdvancedDataGridColumn dataField="name" headerText="name"/>
    <mx:AdvancedDataGridColumn dataField="code" headerText="code"/>
   
   </mx:columns>
  </mx:AdvancedDataGrid>
</mx:VBox>

效果图如下:


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值