2 Replies Latest reply on Dec 4, 2007 7:19 AM by cdclose@gmail.com

    Editable DataGrid With DateField

    cdclose@gmail.com
      I'm new to flex and struggling with the editable DataGrid. I have a DataGrid with an ItemRenderer that outputs a DateField. I can't figure out how to get the new value of the DateField after the edit.

      Here is my DataGrid (the endDate column):

      <mx:DataGrid id="allHistoryGrid" dataProvider="{allEntries}" height="313" width="782" y="-4" itemEditEnd="saveGridChange(event)" editable="true">
      <mx:columns>
      <mx:Array>
      <mx:DataGridColumn dataField="dietDescription" headerText="Diet"/>
      <mx:DataGridColumn dataField="allergyDescription" headerText="Allergy"/>
      <mx:DataGridColumn dataField="labDescription" headerText="Lab"/>
      <mx:DataGridColumn dataField="labResult" width="50" headerText="Result" itemRenderer="LabResultItemRenderer"/>
      <mx:DataGridColumn dataField="medicationDescription" headerText="Medication"/>
      <mx:DataGridColumn dataField="height" width="65" headerText="Height" itemRenderer="HeightItemRenderer"/>
      <mx:DataGridColumn dataField="weight" headerText="Weight" itemRenderer="WeightItemRenderer"/>
      <mx:DataGridColumn dataField="bmi" width="35" headerText="BMI" itemRenderer="BmiItemRenderer"/>
      <mx:DataGridColumn dataField="circumference" width="45" headerText="Circ." itemRenderer="CircumferenceItemRenderer"/>
      <mx:DataGridColumn headerText="Start Date" width="75" sortCompareFunction="startDateSortCompare">
      <mx:itemRenderer>
      <mx:Component>
      <mx:VBox clipContent="false">
      <mx:DateFormatter id="dateFormatter" formatString="MM/DD/YYYY"/>
      <mx:Text width="100" text="{dateFormatter.format(data.startDate)}"/>
      </mx:VBox>
      </mx:Component>
      </mx:itemRenderer>
      </mx:DataGridColumn>
      <mx:DataGridColumn dataField="endDate" width="45" headerText="End Date" itemRenderer="EndDateItemRenderer" rendererIsEditor="true"/>
      <mx:DataGridColumn id="deleteEntry" width="50" textAlign="center"
      headerText="Delete" sortable="false"
      itemRenderer="DeleteItemRenderer"/>
      </mx:Array>
      </mx:columns>
      </mx:DataGrid>

      Here is my itemRenderer:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:VBox xmlns:mx=" http://www.adobe.com/2006/mxml"
      paddingLeft="16" horizontalAlign="center">

      <mx:DateFormatter id="dateFormatter" formatString="MM/DD/YYYY"/>
      <mx:DateField x="16" y="67" id="AllHistoryEndDate" text="{dateFormatter.format(data.endDate)}"/>

      </mx:VBox>

      How do I get the new value in the saveGridChange function?

      private function saveGridChange(event:DataGridEvent):void {

      ??????

      }