I assume you've been to my blog and looked at the checkbox examples there. I haven't had time to go through your code, but the idea is that a checkbox's selected state usually either reflects the selected state of the row, or the Boolean value of some field in the data, generally one represended by the column.
Any code that sets a renderer's selected state is going to have it get reset when scrolling or other data updates, even updates to other rows occur. One of my blog examples has the renderer mirror the selection model, the other reflects data fields. -Alex From: [email protected] [mailto:[email protected]] On Behalf Of Simon Bailey Sent: Sunday, December 21, 2008 2:08 PM To: [email protected] Subject: Re: [flexcoders] DataGrid and CheckBoxes Just to note its not that my renderer is now not driven from the data property but that one selected checkbox selects the whole row and individual checkbox selection i.e. within a column and row is the struggle whilst ensuring on scroll things dont get messed right up? On 21 Dec 2008, at 13:19, Simon Bailey wrote: Alex could you please if possible give an example of how you would manage the selected check box and deselection ! of the other items within the renderer? On 21 Dec 2008, at 05:35, Alex Harui wrote: Manipulating renderers from outside the renderer is usually the cause of trouble like this. The renderer should be completely driven from the data property. If you change the data property make sure the dat! a is bindable or managed or else, call itemUpdated so notifica! tions ge t sent. From: [email protected] [mailto:[email protected]] On Behalf Of Simon Bailey Sent: Saturday, December 20, 2008 1:25 PM To: [email protected] Subject: [flexcoders] DataGrid and CheckBoxes Hi, Ok DataGrids have been the bane of my life recently due to various reasons and I have made some significant headway with various issues I have had. My last (fingers crossed) problematic area I have decided to throw out there as enough is enough :) http://www.nutrixinteractive.com/apps/datagrid_example/ (view source is enabled)! Here is a comparison example I have been working on with the grid on the left built to show a couple of problems I had right at the start. The grid on the right was my fixed and working grid, that is until I tested with a larger record set and yet another issue came to rise :( The problem is simple and occurs sporadically but I must have this working 100%. Only one check box should be selected at a time. If you se! lect a checkbox, scroll about a bit, then scroll down and select another checkbox then scroll madly up and down you will notice that the selected check box un-selects. Now this does not occur all the time as I said and pretty much is fairly solid but the point is it does happen so I could really! do with some eyes on this to come up with an explanation please? The main methods handling the checkbox selection are: In the default application: private function onChange( e:ListEvent ):void { for ( var i:int = 0; i < e.itemRenderer.parent.numChildren; i &#! 43;+ ) { if( e.itemRenderer.parent.getChildAt(i) is CheckBox &&a! mp; e.it emRenderer.parent.getChildAt(i) != e.target &nb! sp; && CheckBox(e.itemRenderer.parent.getChildAt(i)).selected != false ) { CheckBox(e.! itemRenderer.parent.getChildAt(i)).selected = f! alse; } } } In the renderer: override protected function commitProperties():void { super.commitProperties(); if (owner is ListBase) { if( ListBase(owner).isItemSelecte! d(d ata) == true && data['row'] == listData.rowIndex && data['col'] == listData.columnIndex ) selected = true; &n! bsp; else selected = false; } } override protected function clickHandler(event:MouseEvent):void { super.clickHand! ler(event); this.visible = false; data['col'] = listData.columnIndex; data['row'] = listData.rowIndex; // Not sure if we need to but visuals i.e. visibility has changed so best do it invalidateDisplayList(); &! nbsp;&nb sp; // Dispatch an event picked up by the datagrid which will deselect cb's dispatchEvent( new ListEvent( ListEvent.CHANGE, true, false, listData.columnIndex, listData.rowIndex, null, this ) ); }

