Hi, Greg. In-line, interactive renderers are often a PITA to code and use and understand.
Consider building or getting a "real" checkbox item renderer. I use one I implemented in mxml, but there are several examples that use optimized AS. Here is one: http://www.returnundefined.com/2007/11/efficient-reusable-and-centered-c heckbox-renderers-for-datagrids Tracy ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of greg_lafrance Sent: Sunday, August 24, 2008 12:58 PM To: [email protected] Subject: [flexcoders] Re: CheckBox DataGrid column itemRenderer not updating. Please help. Hmmm... That didn't seem to update the dataProvider. --- In [email protected] <mailto:flexcoders%40yahoogroups.com> , "Don Kerr" <[EMAIL PROTECTED]> wrote: > > setting editorDataField to "selected" works for me.... > > <mx:DataGridColumn headerText="Region Review" width="120" > dataField="regionReview" editorDataField="selected" > rendererIsEditor="true"> > <mx:itemRenderer> > <mx:Component> > <mx:CheckBox/> > </mx:Component> > </mx:itemRenderer> > </mx:DataGridColumn> > > > Don Kerr > > > --- In [email protected] <mailto:flexcoders%40yahoogroups.com> , "greg_lafrance" <glafrance@> wrote: > > > > I have a column in a datagrid using CheckBox as itemRender, and user > > checks CheckBoxes they want to send email for. > > > > But after user checks the CheckBoxes, the data provider has not been > > updated. > > > > Should I try to get the dataProvider to get the updated > > checked/unchecked state of the CheckBoxes (and if so, how), or should > > I simply examine the "selected" property of each of the Checkboxes > > (and if so, how). > > > > Someone in the Adobe Flex forum suggested in CheckBox you have to > > add "change" event handler and when it is called set the property. > > change="data.sendEmail = chk_box_id.selected", but Flex prevents me > > from using an ID in this case for the itemrenderer CheckBox. > > > > I tried this but then the checkBox does not get checked when you > > click it: > > > > change="data.sendEmail=this.selected" > > > > Thanks very much. Greg > > > > ------------- data/contactsTest.xml ------ > > <?xml version="1.0" encoding="utf-8" ?> > > <contacts> > > <contact> > > <name>Frank Bords</name> > > <sendEmail>false</sendEmail> > > </contact> > > <contact> > > <name>Dave Harris</name> > > <sendEmail>false</sendEmail> > > </contact> > > <contact> > > <name>Lee Travis</name> > > <sendEmail>false</sendEmail> > > </contact> > > <contact> > > <name>Glen Matin</name> > > <sendEmail>false</sendEmail> > > </contact> > > <contact> > > <name>Gary Curtis</name> > > <sendEmail>false</sendEmail> > > </contact> > > </contacts> > > --- Test.mxml --- > > <?xml version="1.0" encoding="utf-8"?> > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> " > > creationComplete="init()"> > > <mx:Script> > > <![CDATA[ > > import mx.rpc.events.ResultEvent; > > import mx.collections.XMLListCollection; > > import mx.controls.DataGrid; > > > > [Bindable] > > private var contactData:XMLListCollection; > > > > private function init():void { > > contactService.send(); > > } > > > > private function sendEmail(event:MouseEvent):void{ > > for each(var item:XML in contacts.dataProvider){ > > trace(item.sendEmail); > > } > > } > > > > private function contactResultHandler (event:ResultEvent):void{ > > contactData = new XMLListCollection > > (event.result.contact); > > } > > ]]> > > </mx:Script> > > <mx:HTTPService id="contactService" url="data/contactTest.xml" > > resultFormat="e4x" > > useProxy="false" result="contactResultHandler(event)"/> > > <mx:DataGrid id="contacts" dataProvider="{contactData}" > > rowCount="5"> > > <mx:columns> > > <mx:DataGridColumn dataField="name" headerText="Name" > > width="100"/> > > <mx:DataGridColumn dataField="sendEmail" headerText="Email > > Contacts" width="100" > > rendererIsEditor="true"> > > <mx:itemRenderer> > > <mx:Component> > > <mx:CheckBox label="Send Email" > > selectedField="{data.sendEmail as Boolean}" > > change="data.sendEmail=this.selected" > > paddingLeft="5"/> > > </mx:Component> > > </mx:itemRenderer> > > </mx:DataGridColumn> > > </mx:columns> > > </mx:DataGrid> > > <mx:Button label="Email Checked Contacts" fontSize="14" > > color="0xAB45C4" > > click="sendEmail(event)"/> > > </mx:Application> > > >

