2 Replies Latest reply on Aug 16, 2006 11:43 AM by macromichael

    Datagrid itemrenderer listdata Error

    macromichael Level 1
      I am having an issue with a datagrid that if you have an itemRenderer, and an itemEditor, the listdata is null. If you only specify either the itemRenderer, or the itemEditor, it works. In the example code below, the first column works, and the second gives a null exception. Perhaps someone with greater insight can share their brilliance on this one.

      <?xml version="1.0"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns:local="*">

      public var initDG:Array = [
      {startdate: new Date('Fri May 5 08:00:00 GMT-0600 1905'),enddate: new Date('Fri May 5 09:00:00 GMT-0600 1905')},
      {startdate: new Date('Fri May 5 08:00:00 GMT-0600 1905'),enddate: new Date('Fri May 5 09:00:00 GMT-0600 1905')} ];
      <mx:Component id="editdt">
      <mx:TextInput preinitialize ="initTA();">

      import mx.data.messages.DataAssociationMessage;
      import mx.controls.dataGridClasses.DataGridListData;
      import flash.events.Event;

      private var datein:Date;

      public function initTA():void {
      addEventListener("dataChange", handleDataChanged);

      public function get newTime ():Date {
      trace("get "+text);
      // validate
      return datein;//textin.text;

      public function handleDataChanged(event:Event):void {
      // Cast listData to DataGridListData.
      var myListData:DataGridListData = DataGridListData(listData);
      var field:String=myListData.dataField;
      // Access information about the data passed to the item renderer.
      if (field == "startdate"){
      datein = event.currentTarget.data.startdate;
      } else {
      datein = event.currentTarget.data.enddate;
      <mx:RegExpValidator expression="^(\d|1[0-2]):[0-5]\d [apAP][mM]$"/>
      <mx:DateFormatter id="df" formatString="L:NN A"/>

      <mx:DataGrid id="myGrid" dataProvider="{initDG}" variableRowHeight="true" editable="true">
      <mx:DataGridColumn dataField="enddate" itemEditor="{editdt}" editorDataField="newTime"/>
      <mx:DataGridColumn dataField="startdate" itemEditor="{editdt}" editorDataField="newTime">
      <mx:VBox clipContent="false">
      <mx:DateFormatter id="df" formatString="L:NN A"/>
      <mx:Text width="100" text="{df.format(data.startdate)}"/>

      Michael Hunter -