8 Replies Latest reply on Dec 16, 2009 4:34 AM by rick@cat

    Dynamically setting editable=false during itemRendering

    rick@cat

      I have the following code I am trying to get to work but cannot for the life of me get to the "quantity" cells editable property to change it dynamically. Any help would be very much appreciated...

       

      package controls{
         
          import mx.controls.Alert;
          import mx.controls.Label;
          import mx.controls.DataGrid;
          import mx.controls.dataGridClasses.DataGridListData;
          import mx.controls.dataGridClasses.DataGridColumn;
          import mx.controls.listClasses.*;

          public class setTextColor extends Label {

              private const TRUE_COLOR:uint = 0x000000; // black
              private const FALSE_COLOR:uint = 0x888888; // grey
              private const QTY_COLOR:uint = 0x0000ff; // blue

              override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
                  super.updateDisplayList(unscaledWidth, unscaledHeight);

                   var dField:String = DataGridListData(listData).dataField;
                  
                  var myListData:DataGridListData = DataGridListData(listData);
                  var colIdx:int = myListData.columnIndex;
                  var rowIdx:int = myListData.rowIndex;

                   var dg:DataGrid = DataGrid(listData.owner)
      ;
                  
                   if(dField == 'quantity'){
                       setStyle("color", ( data.display == 'false' ) ? FALSE_COLOR : QTY_COLOR);
                       if(data.display == 'false'){
                           //set this cell as editable = false;
                       }
                   }
                   else{
                      /* Set the font color based on the display field. */
                      setStyle("color", ( data.display == 'false' ) ? FALSE_COLOR : TRUE_COLOR);
                  }
              }
          }
      }

       

      I tried to get a reference to the owner datagrid as you can see in blue but it does not have the .getItemAt() method available like it does in MXML. So, I'm stuck.

       

      TIA,

      Rick