Oops, missed that it was 1.5, thanks for the clarification. Tracy
________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Doug Lowder Sent: Monday, March 12, 2007 2:05 PM To: [email protected] Subject: [flexcoders] Re: Checkbox in Celrenderer Problem That's an excellent example for Flex 2. I forgot to mention my reply was based on the original poster's scenario using Flex 1.5. Similar situations with respect to cell renderer re-use though. --- In [email protected] <mailto:flexcoders%40yahoogroups.com> , "Tracy Spratt" <[EMAIL PROTECTED]> wrote: > > Here is a simple example: > > http://www.cflex.net/showfiledetails.cfm? <http://www.cflex.net/showfiledetails.cfm?> ChannelID=1&Object=File&objectI > D=559 > > Tracy > > > > ________________________________ > > From: [email protected] <mailto:flexcoders%40yahoogroups.com> [mailto:[email protected] <mailto:flexcoders%40yahoogroups.com> ] On > Behalf Of Doug Lowder > Sent: Monday, March 12, 2007 1:05 PM > To: [email protected] <mailto:flexcoders%40yahoogroups.com> > Subject: [flexcoders] Re: Checkbox in Celrenderer Problem > > > > It's not a bug. Cell renderers are created only for visible objects > in a list control, not for every single item in the list. Renderers > get reused for items in the list, which provides a performance gain > compared to creating a renderer object for every list item. What you > are seeing is a renderer that has been reused for multiple items, but > hasn't been told completely how to transfer its data to and from the > list item. The result is seemingly unpredictable behavior. > > You need to set the state of your renderer's checkbox in the setValue > () method, and set the value of the dataprovider field when the user > clicks on the checkbox to change its state. Assuming your > dataprovider has some boolean field that corresponds to the state of > your checkbox control, then in setValue() you should have something > like the following, where "item" is the data object passed to the > function: > > myCheckBox.selected = item[getDataLabel()]; > > In the checkbox's click handler, you should have something like the > following that sets the value of a field in the dataprovider > according to the checkbox state: > > listOwner.editField( > getCellIndex().itemIndex, getDataLabel(), myCheckBox.selected); > > The listOwner, getCellIndex, and getDataLabel properties are values > that get passed to all cell renderers. > > HTH, > Doug > > --- In [email protected] <mailto:flexcoders%40yahoogroups.com> <mailto:flexcoders% 40yahoogroups.com> > , "digital_eyezed" <flexcoders@> > wrote: > > > > Hi, > > > > I have a cellrenderer for a datagrid which has a simple checkbox in > it. > > > > My problem is, when I click the checkbox, another checkbox (which is > > outside the scroll area of the datagrid) is also checked and so on > > every row which is equal to the rowcount of the datagrid. > > > > Is this a bug? > > > > How do I get around this problem? > > > > Best Regards, > > > > Iain (Flex 1.5) > > >

