1 Reply Latest reply on Jul 13, 2010 6:04 AM by meirotstein

    Custom ItemRenderer makes the column non editable

    meirotstein

      Hi Folks,

       

      I have a DataGrid which s editable, I've created a custom ItemRenderer to deal with special format needed for Date variables, for that I extended the mx:Text class in order to get access to the listData.dataField variable.

       

      The problem is that this makes the column non-editable, the other column in the table are editabe.

       

      When I used a VBox container the column was editable however I didn't get access to the listData, which I need for the dataField variable.

       

      Any help will be appreciated.

       

      Thanks,

      MR.

       

      Here is the my DateItemRenderer code:

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Text xmlns:fx="http://ns.adobe.com/mxml/2009" 
                                      xmlns:s="library://ns.adobe.com/flex/spark" 
                                      xmlns:mx="library://ns.adobe.com/flex/mx">
           <fx:Declarations>
                <!-- Place non-visual elements (e.g., services, value objects) here -->
           </fx:Declarations>
           <fx:Script>
                <![CDATA[
                     import aslib.common.Constants;
                     import aslib.common.Utils;
                     import aslib.connection.JSONConnector;
                     
                     import mx.controls.dataGridClasses.DataGridListData;
                     import mx.controls.listClasses.ListData;
                     import mx.formatters.DateFormatter;
                     
                     [Bindable]
                     private var _dispValue:String;               
                     
                     public function dateStr(val:Object):String {
                          var innerDt:Date;
                          if(!(val is Date))
                               innerDt = Utils.convertDateStr(val as String);
                          else
                               innerDt = val as Date;
                          if(innerDt){
                               var df:DateFormatter = new DateFormatter();
                               df.formatString = "DD/MM/YYYY";
                               var formatedDate:String = df.format(innerDt);                                                       
                               return formatedDate;
                          }else{
                               return "";
                          }
                     }
                     
                     public override function set data(value:Object):void {
                          
                          var date:Object = value[(listData as DataGridListData).dataField];
                          if(date){
                               _dispValue = dateStr(date);
                          }
                          
                     }
                ]]>
           </fx:Script>
           <mx:text>{_dispValue}</mx:text>
      </mx:Text>