Your theory seems close.

 

First, what is that click handler stuff doing?  It really should just
update a property on the dataProvider item that controls the selected
state of the checkbox. 

That loop is unselecting the checkbox in every row in the DG.  That does
not make sense to me.

 

One suggestion: set data gets called *very* often.  It is better to set
an instance varialble with the data object in that function, call
invalidateProperties(), then do the actual visual work in
commitProperties().

 

But what you have should work, it is just inefficient.

 

Debug the code that sets the  selected state.  I'd break that ternary
expression into steps and trace or step through to see what is
happening.

 

Tracy 

 

________________________________

From: [email protected] [mailto:[email protected]] On
Behalf Of Simon Bailey
Sent: Monday, December 29, 2008 5:46 PM
To: [email protected]
Subject: Re: [flexcoders] Re: 2 Datagrid issue

 

http://www.nutrixinteractive.com/apps/datagrid_example/dg.html
<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() );

}

 

 

 

 

Reply via email to