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 select 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
                        && e.itemRenderer.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 ) );
}

Reply via email to