How small a test case can you build?  I think it is time to see how you're 
trying to wire this up.

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf 
Of Glenn Jones
Sent: Monday, January 12, 2009 9:21 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] DataGrid selectAll problem


I've tried setting just selectedIndices - same result

In my CheckBoxDataGrid.selectAll() method, I tried calling 
invalidateProperties/invalidateList/validateNow - same result.

In my CheckBoxHeaderRenderer.clickHandler, I tried using callLater to execute 
CheckBoxDataGrid.selectAll() - same result.

I repeated the callLater test after removing 
invalidateProperties/invalidateList/validateNow - same result.

Any suggestions on which operations I should use for callLater()?

As a workaround, I added an event listener for itemEditBeginning on the 
checkboxdatagrid. If the selected item count was > 1,
then I called event.preventDefault().  This actually triggers a crash sometime 
later in mx:DataGrid (line 3889 - itemEditorInstance is null).


On Mon, Jan 12, 2009 at 10:07 AM, Alex Harui 
<aha...@adobe.com<mailto:aha...@adobe.com>> wrote:

I would not set  both selectedItems and selectedIndices.  Probably just 
selectedIndices because it should be faster.



I don't think selectItem will be called if the item is already selected.  Due 
to the way invalidation works, maybe it hasn't been de-selected yet.  
Sometimes, callLater can help in these situations.



From: flexcoders@yahoogroups.com<mailto:flexcoders@yahoogroups.com> 
[mailto:flexcoders@yahoogroups.com<mailto:flexcoders@yahoogroups.com>] On 
Behalf Of Glenn Jones
Sent: Saturday, January 10, 2009 4:52 PM
To: flexcoders@yahoogroups.com<mailto:flexcoders@yahoogroups.com>
Subject: Re: [flexcoders] DataGrid selectAll problem



I started with the example from your blog dated Feb 2008 
(CheckBoxListAndDataGrid).

To deselect the other rows, the checkbox column header renderer calls a 
'selectAll()' method on the CheckBoxDataGrid
with  a flag of false.  That method builds two arrays - one for all items in 
the collection and one for all indices in the collection.
It then replaces mx:DataGrid.selectedItems and selectedIndices with new arrays. 
In the deselect case, the new arrays are empty.
In the select all case then have all items/indices.

Visually, selectAll true/false seems to work when it's called. But in the 
use-case I describe below I'm counting on the
mx:DataGrid.selectItem() to be called in order to deselect rows in the case 
that a single row is selected.
Based on trace statements, I know that mx:DataGrid.selectItem() is never called 
when the problem occurs

Is there something about the way I'm selecting things which causes the 
selectItem() to not be called?

I tried replacing just selectedItemds or just selectedIndicies or both. it 
doesn't seem.

Thanks,
Glenn

On Fri, Jan 9, 2009 at 1:11 AM, Alex Harui 
<aha...@adobe.com<mailto:aha...@adobe.com>> wrote:

Which example did you start with?  Which event do you use to deselect the other 
rows, and what does that code look like?



From: flexcoders@yahoogroups.com<mailto:flexcoders@yahoogroups.com> 
[mailto:flexcoders@yahoogroups.com<mailto:flexcoders@yahoogroups.com>] On 
Behalf Of Glenn Jones
Sent: Thursday, January 08, 2009 9:49 PM
To: flexcoders@yahoogroups.com<mailto:flexcoders@yahoogroups.com>
Subject: [flexcoders] DataGrid selectAll problem



Hi,

I'm using Flex 3.2 and I have a DataGrid which implements a column of 
checkboxes to select rows.  I started with Alex' example.
Then I added a header renderer on the checkbox column such that if check the 
header, then all rows are selected.
To implement the select all behavior, I'm creating an array of indices for 
[0..n] and assigning that array to mx:DataGrid.selectedIndices.

For the most part this works fine.

But if the DataGrid is editable, then I sometimes have a problem. The problem 
is that if all rows are selected, and you click on
an editable cell, sometimes the cell becomes editable without deselecting all 
of the other rows. The behavior I want is that
if you start editing a cell, then just that row becomes selected. This happens 
some of time, but not all of the time.

If the grid is non-editable, then I can't reproduce the problem.

I overrode mx:DataGrid.selectItem() in order to clear the checkbox in the 
header renderer any time a single item is selected.  I've
noticed that when the problem behavior occurs, the mx:DataGrid.selectItem() 
method is never called.

It's almost like there's some race condition between selecting an item and 
starting a cell edit.

Any ideas on how I could work around this?

Thanks,
Glenn




Reply via email to