如何根据行数为数据网格生成序列号?
<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>