http://www.nutrixinteractive.com/apps/datagrid_example/dg.html
Hmmm, jeez, crack one and always get another....its a bit unreliable
on scrolling I have noticed?
On 29 Dec 2008, at 21:30, Simon Bailey wrote:
With a slightly clearer head I think this may be the solution,
handled within the custom renderer:
override public function set data(value:Object):void
{
if( value != null )
{
super.data = value;
selected = ( data.column == listData.columnIndex &&
data.row == listData.rowIndex ) ? data.selected :
false;
}
}
override protected function clickHandler(event:MouseEvent):void
{
super.clickHandler(event);
for ( var i:int = 0; i <
DataGrid( listData.owner ).dataProvider.length; i ++ )
{
DataGrid( listData.owner ).dataProvider[i].selected = false;
}
data.selected = selected;
data.row = listData.rowIndex;
data.column = listData.columnIndex;
( listData.owner as CustomGrid ).invalidateList();
IList(DataGrid(owner).dataProvider).itemUpdated(data);
}
Any thoughts on this technique?
Cheers,
Simon
On 29 Dec 2008, at 20:31, Simon Bailey wrote:
Ok, my apologies for the irritating vagueness in my explanation:
What I am trying to do is populate 2 grids using an array of value
objects.
Each grid uses various properties of the said value objects, some
different and some the same.
I have a custom render which extends checkbox and thus displays
checkboxes throughout the grids.
I simply want to be able to select ONE checkbox in each grid.
If a check box in one grid is selected and its row is different to
the currently selected check box in the second grid, I will be
aiming to then:
1) Deselect the check box in the second grid.
2) Highlight the row in the second grid to match the newly selected
row in the first grid.
For this to happen I have followed the typical route i.e. have as
much of the handling of the check box selections within the
renderer itself and driven from the data property e.g.
override public function set data(value:Object):void
{
if( value != null )
{
super.data = value;
selected = ( data.column == listData.columnIndex &&
data.row == listData.rowIndex ) ?
data.selected : false;
}
}
override protected function clickHandler(event:MouseEvent):void
{
super.clickHandler(event);
data.selected = selected;
data.row = listData.rowIndex;
data.column = listData.columnIndex;
( listData.owner as CustomGrid ).invalidateList();
IList(DataGrid(owner).dataProvider).itemUpdated(data);
}
btw duplicating an Array using concat() did not work unfortunately
as (adobe doc quote) 'changes are still made to both arrays. So I
used (adobe docs):
private function clone( source:Object ):*
{
var myBA:ByteArray = new ByteArray();
myBA.writeObject( source );
myBA.position = 0;
return( myBA.readObject() );
}