Flex datagrid with dropdownlist in a particular row
I'm having difficulty figuring out how to add a dropdownlist 开发者_StackOverflow社区control to only a single row of a data grid. For example, if I have two rows of data in the grid, I want the top to be the normal text from the data provider, and the second row to be a dropdownlist (bound to an array collection). I've searched high and low for a solution to no avail. Any help is much appreciated.
Thanks,
Conceptually you need an itemRenderer function, which is not implemented in the MX DataGrid. ( It may be in the new Spark one, but I don't know).
In lieu of that, just create an itemRenderer to conditionally display the DropDownList. Something like this:
<s:MXDataGridRenderer dataChange="onDataChange()">
<fx:script>
public function onDataChange():void{
if((this.ListData as DataGridListData).rowIndex == 0){
label.visible == false;
ddl.visible == true;
} else {
label.visible == true;
ddl.visible == false;
}
}
</fx:Script>
<s:Label id="label" />
<s:DropDownList id="ddl" />
</s:MXDataGridRenderer>
精彩评论