rcom10002 / ccgclient

Automatically exported from code.google.com/p/ccgclient
0 stars 1 forks source link

为Datagrid添加编号 #32

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
如题

Original issue reported on code.google.com by rcom10002 on 16 Aug 2009 at 11:42

GoogleCodeExporter commented 9 years ago
ccglib添加工具方法,参考下面的例子

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
    creationComplete="initApp()">
<mx:Script><![CDATA[
  import mx.collections.ArrayCollection;
  import mx.controls.Alert;

  [Bindable]private var _acDP:ArrayCollection;

 public function initApp():void
 {
   var oItem:Object;
   _acDP = new ArrayCollection();
   oItem = {Album:"The Lost Chord", Artist:"The Moody Blues", Price:"15.99" };
   _acDP.addItem(oItem);
   oItem = {Album:"Meddle", Artist:"Pink Floyd", Price:"17.99" };
   _acDP.addItem(oItem);
   oItem = {Album:"Trespass", Artist:"Genesis", Price:"18.99" };
   _acDP.addItem(oItem); 

 }//initApp

  private function lfRowNum(oItem:Object,iCol:int):String
  {
    var iIndex:int = _acDP.getItemIndex(oItem) + 1;
    return String(iIndex);
  }

]]></mx:Script>

<mx:VBox>
 <mx:DataGrid id="dgSource" dataProvider="{_acDP}" 
     editable="true" >
    <mx:columns>
      <mx:Array>
        <mx:DataGridColumn headerText="Row#" labelFunction="lfRowNum"  />
        <mx:DataGridColumn headerText="Album" dataField="Album"  />
        <mx:DataGridColumn headerText="Artist" dataField="Artist" />
        <mx:DataGridColumn headerText="Price" dataField="Price" />
       </mx:Array>
    </mx:columns>
  </mx:DataGrid>
</mx:VBox>
</mx:Application>

Original comment by rcom10002 on 18 Aug 2009 at 4:01