flex DataGridColumn 固定序号
发布时间:2020-12-15 04:08:07 所属栏目:百科 来源:网络整理
导读:?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:"
<?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> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |