2011-05-04 46 views

回答

0

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> 
<mx:Script> 
    <![CDATA[ 
     import mx.collections.ArrayCollection; 
     [Bindable] 
      public var arrColl:ArrayCollection = new ArrayCollection([{col1:'',col2:'10',col3:'20'},{col1:'',col2:'10',col3:'20'},{col1:'',col2:'10',col3:'20'}]) 
      public function generateSerialId():void 
      { 

      var c:int= 0; 
      for each(var obj:Object in arrColl) 
     { 
      obj.col1 = c; 
      arrColl.removeItemAt(c); 
      arrColl.addItemAt(obj,c); 
      c++; 

     } 
     arrColl.refresh(); 
     }  
    ]]> 
</mx:Script> 
<mx:DataGrid x="2" y="63" dataProvider="{arrColl}"> 
    <mx:columns> 
     <mx:DataGridColumn headerText="Column 1" dataField="col1"/> 
     <mx:DataGridColumn headerText="Column 2" dataField="col2"/> 
     <mx:DataGridColumn headerText="Column 3" dataField="col3"/> 
    </mx:columns> 
</mx:DataGrid> 
<mx:Button x="100" y="235" label="SerialID" click="generateSerialId()"/> 
</mx:Application> 
+0

首先10Q人士Himanshu,但如何做到與該按鈕我的意思是序列號應該生成一旦數據網格加載... – 2011-05-04 07:17:14

+0

我打電話generateSerialId創作完成的DataGrid和它的工作原理精細。 – himanshu 2011-05-04 07:25:13

+0

我可以知道如何使用labelFunction生成序列號嗎? – 2011-05-04 09:09:52