<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" >
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
private var employees:ArrayCollection = new ArrayCollection([
{name:"张三",phone:"123456",email:"123456@qq.com"},
{name:"李四",phone:"1234567",email:"1234567@qq.com"},
{name:"王五",phone:"1234568",email:"1234568@qq.com"},
{name:"刘六",phone:"1234569",email:"1234569@qq.com"}
]);
//固定序号labelFunction函数
private function RowNum(oItem:Object,iCol:int):String
{
// var iIndex:int = employees.getItemIndex(oItem) + 1; //在当前集合中那个位置(便于自己理解,可能解释不准确)
var iIndex:int = employees.source.indexOf(oItem) + 1; //在原来集合中那个位置(便于自己理解,可能解释不准确)
return String(iIndex);
}
]]>
</mx:Script>
<mx:DataGrid id="dg" color="0x323232" width="100%" rowCount="5" dataProvider="{employees}">
<mx:columns>
<mx:DataGridColumn id="num" dataField="orderId" headerText="序号" width="50" labelFunction="RowNum" sortable="false"/>
<mx:DataGridColumn dataField="name" headerText="姓 名"/>
<mx:DataGridColumn dataField="phone" headerText="电 话"/>
<mx:DataGridColumn dataField="email" headerText="邮 箱"/>
</mx:columns>
</mx:DataGrid>
</mx:Application>
flex DataGridColumn 固定序号
最新推荐文章于 2014-08-26 13:46:04 发布