Someone on flexcoders asked how you would create an itemRenderer which sometimes displayed a ComboBox while not displaying it other times. I decided to try and create this itemRenderer. Since the visibility of this ComboBox would be determined by the data, I created a custom itemRenderer that changes the visibility of a ComboBox and a Label in the set data function.
Here is the Demo and Code –
I did not choose to use an editable DataGridColumn because in this example, changing one of the ComboBoxes in the “Available Colors” column doesn’t actually change the data for the ‘colors’ property of the dataProvider which is the dataField for this column. Therefore, the default editable DataGrid code doesn’t work since that code expects that if I edit a cell in the “Available Colors” column, I am wanting to change the ‘colors’ property in some way. Instead, I am handling all changes to data in my itemRenderer. I am updating my DataGrid’s dataProvider on the change event of the ComboBox.
Note, that this is the way that I solved this problem. This doesn’t necessarily reflect best practice or anything. I’m not 100% sure what best practice for this scenario is. I’m just providing one solution. Thanks!