Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>What's happening here is that Flex only creates itemRenderer instances for the <em>visible</em> columns. When you scroll around, those instances get recycled. So if you scroll down, the RadioButton object that was drawing the first column of the first row may now have changed to instead be drawing the first column of the seventh row. Flex resets the "data" property of the itemRenderer whenever this happens.</p> <p>So while there are 15 rows of data, there are only ever 12 RadioButtons (6 for the "left", and 6 for the "right" for the 6 visible rows), not 30 RadioButtons, as you might expect. This isn't a big problem if you're only <em>displaying</em> the selection, but it becomes more of a problem when you allow updates.</p> <p>To fix the display issue, instead of setting the "dataField" on the column, you can bind the RadioButton's "selected" property to the itemRenderer's data.left (or right) value. You'll then need to make the items in your dataProvider "Bindable".</p> <p>To fix the update issue, since you'd be binding directly to the dataProvider item values, you need to be sure to update them. Since there's isn't one RadioButton per-item, you'll need another scheme for that. In this case I put in a handler that goes and sets the left/right property of each item to "false", except for the "selected" one, which gets set to "true".</p> <p>I updated your example code based on these thoughts. Try something like this:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;mx:Application layout="absolute" xmlns:my="*" xmlns:mx="http://www.adobe.com/2006/mxml"&gt; &lt;mx:RadioButtonGroup id="leftAxisGrp" change="selectItem(leftAxisGrp.selectedValue, 'left');"/&gt; &lt;mx:RadioButtonGroup id="rightAxisGrp" change="selectItem(rightAxisGrp.selectedValue, 'right');"&gt; &lt;/mx:RadioButtonGroup&gt; &lt;mx:AdvancedDataGrid id="readingsGrid" designViewDataType="flat" height="150" width="400" sortExpertMode="true" selectable="false" dataProvider="{adgData.object}"&gt; &lt;mx:columns&gt; &lt;mx:AdvancedDataGridColumn headerText="L" width="25" paddingLeft="6" sortable="false"&gt; &lt;mx:itemRenderer&gt; &lt;mx:Component&gt; &lt;mx:RadioButton groupName="leftAxisGrp" value="{data}" selected="{data.left}"/&gt; &lt;/mx:Component&gt; &lt;/mx:itemRenderer&gt; &lt;/mx:AdvancedDataGridColumn&gt; &lt;mx:AdvancedDataGridColumn headerText="R" width="25" paddingLeft="6" sortable="false"&gt; &lt;mx:itemRenderer&gt; &lt;mx:Component&gt; &lt;mx:RadioButton groupName="rightAxisGrp" value="{data}" selected="{data.right}"/&gt; &lt;/mx:Component&gt; &lt;/mx:itemRenderer&gt; &lt;/mx:AdvancedDataGridColumn&gt; &lt;mx:AdvancedDataGridColumn headerText="" dataField="name" /&gt; &lt;/mx:columns&gt; &lt;/mx:AdvancedDataGrid&gt; &lt;mx:Model id="adgData"&gt; &lt;root&gt; &lt;object left="false" right="false" name="Reddish-gray Mouse Lemur" /&gt; &lt;object left="false" right="false" name="Golden-brown Mouse Lemur" /&gt; &lt;object left="false" right="false" name="Northern Rufous Mouse Lemur" /&gt; &lt;object left="false" right="false" name="Sambirano Mouse Lemur" /&gt; &lt;object left="false" right="false" name="Simmons' Mouse Lemur" /&gt; &lt;object left="false" right="false" name="Pygmy Mouse Lemur" /&gt; &lt;object left="false" right="false" name="Brown Mouse Lemur" /&gt; &lt;object left="false" right="false" name="Madame Berthe's Mouse Lemur" /&gt; &lt;object left="false" right="false" name="Goodman's Mouse Lemur" /&gt; &lt;object left="false" right="false" name="Jolly's Mouse Lemur" /&gt; &lt;object left="false" right="false" name="Mittermeier's Mouse Lemur" /&gt; &lt;object left="false" right="false" name="Claire's Mouse Lemur" /&gt; &lt;object left="false" right="false" name="Danfoss' Mouse Lemur" /&gt; &lt;object left="false" right="false" name="Lokobe Mouse Lemur" /&gt; &lt;object left="true" right="true" name="Bongolava Mouse Lemur" /&gt; &lt;/root&gt; &lt;/mx:Model&gt; &lt;mx:Script&gt; &lt;![CDATA[ private function selectItem(selObject:Object, property:String) : void { for each(var obj:Object in adgData.object) { obj[property] = (obj === selObject); } readingsGrid.invalidateDisplayList(); } ]]&gt; &lt;/mx:Script&gt; &lt;/mx:Application&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload