如何根据行数生成数据网格的序列号?
答案 0 :(得分: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>