Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here is another <a href="http://www.len.ro/2009/08/radio-button-renderer-in-a-datagrid/" rel="nofollow">solution</a> with working example. If you are not using XML data, you will not allow to use parent(). Use outerDocument.dg.dataProvider instead, where dg is id for your DataGrid.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"&gt; &lt;mx:Script&gt; &lt;![CDATA[ public var dp:XML = &lt;users&gt; &lt;user&gt; &lt;name&gt;one&lt;/name&gt; &lt;main&gt;true&lt;/main&gt; &lt;/user&gt; &lt;user&gt; &lt;name&gt;two&lt;/name&gt; &lt;main&gt;false&lt;/main&gt; &lt;/user&gt; &lt;user&gt; &lt;name&gt;tre&lt;/name&gt; &lt;main&gt;false&lt;/main&gt; &lt;/user&gt; &lt;/users&gt;; ]]&gt; &lt;/mx:Script&gt; &lt;mx:VBox&gt; &lt;mx:DataGrid dataProvider="{dp.user}" width="400"&gt; &lt;mx:columns&gt; &lt;mx:DataGridColumn headerText="Name" dataField="name"/&gt; &lt;mx:DataGridColumn headerText="Main"&gt; &lt;mx:itemRenderer&gt; &lt;mx:Component&gt; &lt;mx:HBox horizontalAlign="center"&gt; &lt;mx:Script&gt; &lt;![CDATA[ private function changeMain(event:Event):void{ if(data.main == 'true'){ //nothing data.main = 'true'; }else{ for each(var u:XML in (data as XML).parent().user){ u.main = 'false'; } data.main = 'true'; } } ]]&gt; &lt;/mx:Script&gt; &lt;mx:RadioButton click="changeMain(event)" selected="{(data.main == 'true')}"/&gt; &lt;/mx:HBox&gt; &lt;/mx:Component&gt; &lt;/mx:itemRenderer&gt; &lt;/mx:DataGridColumn&gt; &lt;mx:DataGridColumn headerText="Main value" dataField="main"/&gt; &lt;/mx:columns&gt; &lt;/mx:DataGrid&gt; &lt;/mx:VBox&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