在ActionScript类文件中,添加如下方法:
/**
* 生成datagrid第一列用的序号
*/
private function formatIndexNumber(item:Object, colum:Object):String
{
return indexNumLabelFun(item, colum.mx_internal::owner);
}
public static function indexNumLabelFun(value:Object, dataGrid:Object):String
{
var arr: Array = dataGrid.dataProvider.source;
var indexNum: int = (arr.indexOf(value) + 1);
return indexNum.toString();
}
DataGrid前段显示:
<mx:DataGridColumn headerText="序号" labelFunction="SimpleUtil.formatIndexNumber" width="50"/>