2 Replies Latest reply on Dec 6, 2007 6:19 PM by ntsiii

    RowIndex as DataGridColumn value

    Cacademoniaca
      Is it possible to have the rowIndex of the datagrid showed in a column ?

      I know that I can always add my dataprovider an id column but I would like to skip that!

      Any ideas? How about using an item renderer or something like that?
        • 1. Re: RowIndex as DataGridColumn value
          m_hartnett Level 3
          Here is how I did it. This is based on a number of articles I have read on renderers and I have not completed it yet meaning that I am not sure this is the most effecient / correct use of the renderer. I am not sure the use of the Render event is correct.

          Anyway, it will give you row numbers.

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Canvas
          xmlns:mx=" http://www.adobe.com/2006/mxml"
          xmlns:base="com.febatmon.view.base.*"
          width="100%"
          height="100%"
          paddingLeft="5"
          horizontalScrollPolicy="off"
          verticalScrollPolicy="off"
          initialize="initializeHandler()"
          implements="mx.controls.listClasses.IDropInListItemRenderer, mx.core.IFactory">


          <mx:Script>
          <![CDATA[

          import mx.controls.listClasses.BaseListData;

          [Bindable("dataChange")]
          private var _listData : BaseListData;

          public function initializeHandler() : void {
          this.addEventListener("render", refreshData );
          }

          public function newInstance():* {
          return new RowNbrRenderer();
          }

          public function get listData() : BaseListData {
          return _listData;
          }

          public function set listData( value : BaseListData ) : void {
          _listData = value;
          }

          [Bindable]
          override public function set data(value:Object):void {
          super.data = value;
          }

          public function refreshData( e:Event ):void {

          if(data == null) return;

          statusText.text = this.listData.rowIndex.toString();

          }

          ]]>
          </mx:Script>

          <mx:Label id="statusText" width="100%" height="18" x="16"/>

          </mx:Canvas>
          • 2. Re: RowIndex as DataGridColumn value
            ntsiii Level 3
            You can also use labelFunction if your dataProvider is a collection:
            http://www.cflex.net/showFileDetails.cfm?ObjectID=735
            Tracy