2 Replies Latest reply on Feb 11, 2011 5:48 PM by huangxinghui

    DataGrid Problem

    huangxinghui

      code:

      <mx:DataGrid dataProvider="{dp}" width="100%">
        <mx:columns>
         <mx:DataGridColumn headerText="isSelected" dataField="isSelected" visible="false"/>
         <mx:DataGridColumn headerText="Staff Code" dataField="STAFF_CODE"/>
         <mx:DataGridColumn headerText="Staff Name" dataField="STAFF_NAME"/>
        </mx:columns>
      </mx:DataGrid>

       

      [Bindable]
         private var dp:Array = [
          { STAFF_CODE: "admin", STAFF_NAME: "Sys Admin",isSelected:true},
          { STAFF_CODE: "6073", STAFF_NAME: "testuser",isSelected:false},
          { STAFF_CODE: "dormouse", STAFF_NAME: "no code",isSelected:false}
         ];

       

      click header then can find string.

       

      when i set 'isSelected' column to visible. then i click 'Staff Code', Staff Code will sort, but enter word 't' can find record.

       

      so i see the source code find in DataGrid.as

       

      /**
           *  @private
           *  used by ListBase.findString.  Shouldn't be used elsewhere
           *  because column's itemToLabel is preferred
           */
          override public function itemToLabel(data:Object):String
          {
              return displayableColumns[sortIndex == -1 ? 0 : sortIndex].itemToLabel(data);
          }

       

      so i modified like this:

       

      /**
           *  @private
           *  used by ListBase.findString.  Shouldn't be used elsewhere
           *  because column's itemToLabel is preferred
           */
          override public function itemToLabel(data:Object):String
          {
              return columns[sortIndex == -1 ? 0 : sortIndex].itemToLabel(data);
          }

       

      is this a bug?