0 Replies Latest reply on Mar 25, 2010 6:22 PM by rohit_thakare

    Flex AdvancedDataGrid - ColumnOrder With Formatter and ItemRenderer Question For Experts

    rohit_thakare
      I have a advanceddatagrid that has around 15 columns. Some are string,
      some are numbers
      . I have shown 4 columns below.
      The number columns have formatting done for zero precision and 2
      digits precision
      .  The itemRenderer is just to show Blue Color if the
      number
      is +ve and Red Color if the number is -ve.
      It looks something like below

      <mx:columns>
      <mx:AdvancedDataGridColumn dataField="Name" textAlign"left"/>
      <mx:AdvancedDataGridColumn dataField="Time" textAlign="right"/>
      <mx:AdvancedDataGridColumn dataField="Score" textAlign="right"  formatter="{zeroPrecisionFormatter}" sortable="true"   itemRenderer="ColorRenderer" />
      <mx:AdvancedDataGridColumn dataField="Average" textAlign="right" headerWordWrap="true" formatter="{twoPrecisionFormatter}" itemRenderer="ColorRenderer" />


       

       

       

      I am trying to save the users setting of column order  when he closes
      the application
      and reload with the same order when the user opens the
      applications
      . I am using SharedObjects and below is the code.

      for(var i:int=0; i< adgrid.columns.length;i++){
          
      var columnObject:Object = new Object();
           columnObject
      .columnDataField = adgrid.columns[i].dataField as String;
           columnObject
      .columnHeader =adgrid.columns[i].headerText as String;
           columnObject
      .width = adgrid.columns[i].width;
           columnArray
      .push(columnObject);
      }

      and then I save the columnArray to SharedObject.

      I retrive them
      using the below code

      for(var i:int=0;i<columnArray.length;i++){ 
          adgrid
      .columns[i].dataField =columnArray[i].columnDataField;
          adgrid
      .columns[i].headerText =columnArray[i].columnHeader;
          adgrid
      .columns[i].width = columnArray[i].width;
         
      }

      How can I save and reload the Formatter and ItemRenderer data .
      I am having trouble saving the formatter
      and itemrenderer and
      reloading it again
      .


      I would really appreciate
      if you can shown the code.
      How can I reshuffle the columns but can preserve all the properties of it to though  sharedobject and recover it again