在使用dataGrid时候,有时候会用到渲染器,比如我要使用comboBox做多项选择操作,我就要用到ItemRender.
在flex4中我使用<fx:compoment>嵌入<mx:comboBox>组件。
代码如下:
<mx:itemEditor>
<fx:Component>
<mx:ComboBox width="130" labelField="label" dataProvider="{outerDocument.dayTypeArr}"
selectedIndex="{data.flag}" change="{data.flag = selectedIndex}"/>
</fx:Component>
</mx:itemEditor>
当然这个部分还要加到DataGrid中去。
<mx:DataGrid id="myDataGrid" width="800" editable="true" dataProvider="{initDataGrid}">
<mx:columns>
<mx:DataGridColumn headerText="Id" dataField="Id" editable="false" width="200"/>
<mx:DataGridColumn headerText="city" dataField="city" editable="false" width="200"/>
<mx:DataGridColumn headerText="provice" dataField="provice" editable="false" width="200"/>
<mx:DataGridColumn headerText="total" dataField="total" editable="false" width="200"/>
<mx:DataGridColumn headerText="Year" editable="true">
<mx:XXX>
。。。。。。。。。。。。。。。。。。
</mx:XXX>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
数据源我这里使dayTypeArr
如下所示:
[Bindable]
public var dayTypeArr:ArrayCollection = new ArrayCollection(
[
{label:"工作日", data:1},
{label:"公休日", data:2},
{label:"节假日", data:3}
]);
(待续....)