Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6628231
  • 博文数量: 227
  • 博客积分: 10047
  • 博客等级: 上将
  • 技术积分: 6678
  • 用 户 组: 普通用户
  • 注册时间: 2006-07-11 10:33
个人简介

网上的蜘蛛

文章分类

全部博文(227)

文章存档

2010年(19)

2009年(29)

2008年(179)

分类: 系统运维

2009-01-01 23:34:03

从网站找到的。好像还不止一个例子。 这个还不错。但是还有一个稍微好点的: 。稍稍来看下代码:
The application file:
 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="" layout="vertical" viewSourceURL="srcview/index.html">
<mx:Script>
    <![CDATA[
        import mx.collections.*;

        // If using the array data source, get rid of all the @ preceding all the MXML dataFields
        [Bindable]
        private var serviceData:Array = [
             { name: "Michael Smith", addressLine1:"94 Bismore Lane", addressLine2:"Rahway, NJ", phone:"834-394-2394", networth:65000,
                children:[
                 [
                 {date:"04/12/2006", make:"Chevrolet", model:"Malibu", modelyear:2003, description:"Brake job", parts:195, labor:255, total:450},
                 {date:"10/06/2006", make:"Chevrolet", model:"Malibu", modelyear:2003, description:"New tires", parts:168, labor:200, total:368},
                 {date:"06/24/2007", make:"Chevrolet", model:"Malibu", modelyear:2003, description:"Oil change", parts:12, labor:20, total:32}
                 ]
             ]},
             { name: "Wilma Jeffreys", addressLine1:"349 Hooksie Street", addressLine2:"Hightstown, NJ", phone:"385-094-1903", networth:110000,
                children:[
                 [
                 {date:"02/20/2007", make:"Mercury", model:"Sable", modelyear:2006, description:"20,000 mile", parts:55, labor:400, total:455}
                 ]
             ]},
             { name: "Donald Davies", addressLine1:"94 Bismore Lane", addressLine2:"Rahway, NJ", phone:"834-394-2394", networth:65000,
                children:[
                 [
                 {date:"08/14/2007", make:"Mercedes", model:"SL-550", modelyear:2005, description:"Rotate tires", parts:0, labor:800, total:800},
                 {date:"02/27/2008", make:"Mercedes", model:"SL-550", modelyear:2005, description:"Clean windshield", parts:10, labor:500, total:510}
                 ]
             ]}
    ];
    ]]>
</mx:Script>

<!-- The same thing as an XMLList. We'll use this in the example -->

        
                addressLine1="94 Bismore Lane"
            addressLine2="Rahway, NJ"
            phone="834-394-2394"
            networth="65,000">
            
                
                                          make="Chevrolet"
                         model="Malibu"
                         modelyear="2003"                    
                         description="Brake job"                    
                         parts="195"
                         labor="255"
                         total="450"
                         />
                                          make="Chevrolet"
                         model="Malibu"
                         modelyear="2003"                    
                         description="New tires"                    
                         parts="168"
                         labor="200"
                         total="368"
                         />
                                          make="Chevrolet"
                         model="Malibu"
                         modelyear="2003"                    
                         description="Oil change"                    
                         parts="12"
                         labor="20"
                         total="32"
                         />
                

            
            
    
    
                addressLine1="349 Hooksie Street"
            addressLine2="Hightstown, NJ"
            phone="385-094-1903"
            networth="110,000">
                        
                
                                              make="Mercury"
                         model="Sable"
                         modelyear="2006"                    
                         description="20,000 mile"                    
                         parts="55"
                         labor="400"
                         total="455"
                         />
                

            
                
    

                addressLine1="222 Twoston Road"
            addressLine2="Princeton, NJ"
            phone="495-394-9023"
            networth="890,000">
                        
                
                                             make="Mercedes"
                         model="SL-550"
                         modelyear="2005"                    
                         description="Rotate tires"                    
                         parts="0"
                         labor="800"
                         total="800"
                         />
                                          make="Mercedes"
                         model="SL-550"
                         modelyear="2005"                    
                         description="Clean windshield"                    
                         parts="10"
                         labor="500"
                         total="510"
                         />
                
    
            
                                    
    





" fontSize="
20" color="#FFFFFF" fontWeight="bold" />
" fontSize="
16" color="#FFFFFF" fontWeight="bold"/>

             variableRowHeight="
true"
             width="
98%"
             height="
80%"
             editable="
false"
             textAlign="
center"
             verticalAlign="
top"
             defaultLeafIcon="
{null}"
             sortableColumns="
false"
             useRollOver="
false"
             selectionColor="
#EEEFFF"
             >
    
          {
xmlServiceData}" childrenField="servicesNode" />
        
    
      
         " dataField="
@name"
                width="
80" />             
           " dataField="
@addressLine1"
                width="
150" />
           /
State" dataField="@addressLine2"
                                        width="
150" />
           " dataField="
@phone"
                width="
150" />
           " width="
70" dataField="@networth" />
      
    
         " columnIndex="
1"
                     renderer="
SubDataGrid"
                     columnSpan="
0

The child DataGrid:

 

<?xml version="1.0" encoding="utf-8"?>
<mx:AdvancedDataGrid xmlns:mx=""
                     textAlign="center"
                     sortableColumns="false"
                      alternatingItemColors="['#D8ECFF', '#D8EAEE']"
                      itemClick="Alert.show('You clicked ' + value.@date)"
                     >                 
   <mx:Script>
     <![CDATA[
         import mx.controls.Alert;            
                                     
        override public function set data(value:Object):void
        {
           // set dataProvider    
           dataProvider = value.service;
           
           // If using the array data source, use this instead:
           // dataProvider = value;
           
           // adjust rowCount
           this.rowCount = dataProvider.length + 1;
        }
        
     ]]>
   </mx:Script>

   <!-- If using the array data source, get rid of all the @ preceding all the MXML dataFields -->
   <mx:columns>
     <mx:AdvancedDataGridColumn headerText="Date" fontWeight="bold"
                  dataField="@date"/>
     <mx:AdvancedDataGridColumn headerText="Make"
                          dataField="@make"/>
     <mx:AdvancedDataGridColumn headerText="Model"
                  dataField="@model"/>
     <mx:AdvancedDataGridColumn headerText="Year"
                  dataField="@modelyear"/>
     <mx:AdvancedDataGridColumn headerText="Description"
                  dataField="@description"/>
     <mx:AdvancedDataGridColumn headerText="Parts"
                  dataField="@parts"/>
     <mx:AdvancedDataGridColumn headerText="Labor"
                  dataField="@labor"/>
     <mx:AdvancedDataGridColumn headerText="Total"
                  dataField="@total"/>
    
   </mx:columns>    
</mx:AdvancedDataGrid>

不是很难理解,但是你要懂rendering。

好久没有看Flex了,生疏了好多,还准备用它做点事情呢...

阅读(7315) | 评论(0) | 转发(0) |
0

上一篇:我的08年

下一篇:C++中const用法总结

给主人留下些什么吧!~~