Using a DateField itemRenderer for a Spark DataGrid
Here is another simple example of using a custom itemRenderer in a Spark DataGrid. In this example, I am using an MX DateField component as an inline itemRenderer.
This DataGrid is also editable. Both columns “In Stock?” and “Availability Date” also have the property rendererIsEditor=”true”. This tells the DataGrid that the component specified as the itemRenderer is also the editor for this column. If you do not specify rendererIsEditor=”true”, then, updating the CheckBox or DateField will not actually affect the data. I am setting the selectedDate on the DateField via 2-way dataBinding:
selectedDate="@{data.availabilityDate}"
Here is the code that defines the column using the DateField itemRenderer:
<s:GridColumn headerText="Availability Date" dataField="availabilityDate"
rendererIsEditable="true">
<s:itemRenderer>
<fx:Component>
<s:GridItemRenderer>
<mx:DateField selectedDate="@{data.availabilityDate}"
horizontalCenter="0" verticalCenter="0"
width="90%"/>
</s:GridItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:GridColumn>
Run the sample: DataGrid_DateFieldExample.swf
Source code: DataGrid_DateFieldExample.mxml


Joan-
So no need for the editorDataField property any more? The value displayed is considered to be the value used in the model?
Also, does the Spark DataGrid support drop-in item renderers any more?
Thanks-
Matt
@Matt There is no equivalent in Spark DataGrid to ‘editorDataField’ in the MX DataGrid. In the example, I didn’t set anything except dataField and it seems to work correctly. If you make a selection and then scroll, the selection remains.
hi,
i need use combobox like itemRenderer but i can`t.
You can?
Thanks
Thanks for your efforts, I tried this, however hitting issues, and tried in another way which is working for me, code posted at my blog