Flex Checkbox as Grid item editor and renderer

I have a dataGrid with a few columns that are simply check boxes. The kicker is I want the user to be able to edit those check boxes. So I knew the first step, using the renderer to have the data from the data provider show up in a check box, but I had to do some research for the editor part.

Here is the code snip of the DataGridColumn that should help you out if you were trying to do that same thing. (Warning: the textAlign property may only work in Flex 3).


<mx:DataGridColumn
dataField="isOpen"
headerText="Open"
editable="true"
textAlign="center"
itemEditor="mx.controls.CheckBox"
editorDataField="selected"
itemRenderer="mx.controls.CheckBox"/>


The important part to this that I was missing is:
editorDataField="selected"

This returns the value of the 'selected' property to the data provider, otherwise, by default it looks to return the "text" property, which a check box does not have.

Hope that helps someone.

Comments

Anonymous said…
Thanks - this came in very handy just when I needed. Thanks again!

-Samir
Edward Husar said…
How can you tell if the checkbox is selected or not when it is a datagrid like this?
Anonymous said…
Helps me! Thanks!
Anonymous said…
Thanks a lot. This saved me my day.

Popular posts from this blog

Flex TabNavigator - tab click event?

Flex Advanced Data Grid collapses on refresh

Add and remove lineseries - Flex LineChart