RadioButton in 1st row of DataGrid causing problems – Adobe Flex

actionscriptapache-flexdatagriditemrenderer

I have a DataGrid with RadioButtons in one column using itemRenderer. The DataGrid resides on a TitleWindow which is created and popped-up everytime the user clicks a button. The dataProvider for the DataGrid is an ArrayCollection, and the RadioButtons are selected or not based on a boolean value in each ArrayCollection item when the window and DataGrid is displayed. If the user clicks a different RadioButton in the DataGrid, then the ArrayCollection items are updated with the new boolean values.

The problem is with the RadioButton in the first row keeping its selected value. With the RadioButtons in the all other rows, when the TitleWindow and DataGrid are displayed, the correct RadioButton is selected based on the boolean value from the item in the ArrayCollection. But if the first row's RadioButton is the one that needs to be selected, it isn't. I set up a listener for the valueCommit event on the RadioButtons, and the results are interesting: valueCommit for the RadioButtons in all rows besides the first is fired just once, with the selected value being true. But if the RadioButton in the first row is the one that should be selected, valueCommit is fired 5 times, the first 3 times reporting the selected value as true and last 2 times reporting it as false.

Any help on this would be greatly appreciated. A similar bug has been reported but it doesn't provide any workaround.

UPDATE 12/18/08
OK, valueCommit is fired 5 times, the fourth being false, and the fifth false time, being false, actually corresponds to index 2 in the data ALWAYS, no matter what it is. So 4 times reporting the first RadioButton, with the last time being false, and fifth time reporting index 2 as false. Weird!

Best Answer

Solution: Instead of using RadioButtons as the itemRenderer, I used an image, which works much cleaner and doesn't produce so much unpredictable behavior.

Related Topic