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 data is bindable or managed or else, call itemUpdated
so notifications get 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 ++ )
{
if( e.itemRenderer.parent.getChildAt(i) is
CheckBox
&&a! mp; e.it
emRenderer.parent.getChildAt(i) != e.target
&&
CheckBox(e.itemRenderer.parent.getChildAt(i)).selected != false )
{
CheckBox(e.itemRenderer.parent.getChildAt(i)).selected = false;
}
}
}
In the renderer:
override protected function commitProperties():void
{
super.commitProperties();
if (owner is ListBase)
{
if( ListBase(owner).isItemSelected(data) ==
true
&& data['row'] ==
listData.rowIndex
&& data['col'] ==
listData.columnIndex ) selected = true;
else selected = false;
}
}
override protected function clickHandler(event:MouseEvent):void
{
super.clickHandler(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();
// 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 ) );
}