[flexcoders] Re: Getting selectedItems to properly *select*...

2007-03-15 Thread qnotemedia
--- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote:
 Are you saying that myAC[0] was
 modified so that the sub AC was removed?  I'd go find out what 
 actually got changed.

Actually no - I was simply reading the subAC, and when checking it a 
second time, the subAC was not actually removed, but all of its 
valueObjects were.  i.e. length = 0 as seen in the gif.


All of this said, after banging my head through this last night, I 
found that I was somehhow incorrectly assigning myGrid.selectedItems 
to the foundItems() function's returned Array (which loops and builds 
an array of found items).  I definitely don't prefer to it this way, 
but in the end it was necessary, and its allowed me to move on past 
this!

IMHO, should've been as easy as myGrid.selectedItems = myAC or some 
simple derivative.  I would love to see a more thorough explanation 
of why this didn't work, and if you look at my gifs you can see my 
frustration!  One of those few times where I feel like the debugger 
is just lying to me.

Problem1: qnotemedia.com/wontwork.gif
Problem2: qnotemedia.com/dissapearing.gif


Thanks to all for your input.
 - Chris



RE: [flexcoders] Re: Getting selectedItems to properly *select*...

2007-03-15 Thread Alex Harui
Too hard to tell from this far away.  You'd have to produce a
mini-example and file it as a bug at adobe.com/go/wish.

 

-Alex

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of qnotemedia
Sent: Thursday, March 15, 2007 5:21 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Getting selectedItems to properly
*select*...

 

--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, Alex Harui [EMAIL PROTECTED] wrote:
 Are you saying that myAC[0] was
 modified so that the sub AC was removed? I'd go find out what 
 actually got changed.

Actually no - I was simply reading the subAC, and when checking it a 
second time, the subAC was not actually removed, but all of its 
valueObjects were. i.e. length = 0 as seen in the gif.

All of this said, after banging my head through this last night, I 
found that I was somehhow incorrectly assigning myGrid.selectedItems 
to the foundItems() function's returned Array (which loops and builds 
an array of found items). I definitely don't prefer to it this way, 
but in the end it was necessary, and its allowed me to move on past 
this!

IMHO, should've been as easy as myGrid.selectedItems = myAC or some 
simple derivative. I would love to see a more thorough explanation 
of why this didn't work, and if you look at my gifs you can see my 
frustration! One of those few times where I feel like the debugger 
is just lying to me.

Problem1: qnotemedia.com/wontwork.gif
Problem2: qnotemedia.com/dissapearing.gif

Thanks to all for your input.
- Chris

 



[flexcoders] Re: Getting selectedItems to properly *select*...

2007-03-14 Thread qnotemedia
Got it!

It appears that selectedItems is dependent on the data being 
*absolutely identical* to the dataProvider. And while I thought my data 
was identical, it really wasn't. In the debugger, if you look at a 
variable, its always: Array (@123456). What I found was that although 
the data was definitely the same, that number was not.

To fix the problem, I centralized all data to go through one data 
manager, whereas before I was reinitializing a different data component 
in each component.

So now, I'm basically calling parentApplication.dataManager.someFunction
() from all of my components. This isn't good quite frankly, but by 
doing so, the @123456 is always the same.

If anyone else can think of a better way, I'm all ears... 



RE: [flexcoders] Re: Getting selectedItems to properly *select*...

2007-03-14 Thread Gordon Smith
If you set selectedItems, the array you set it to needs to contain
actual object references to particular data items in the dataProvider.
It can't simply contain objects with the same data.
 
If you want to set the selection based on data, you'll have to loop
through all the items, inspect whether each item has the data you want,
and select it if so.
 
- Gordon



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of qnotemedia
Sent: Wednesday, March 14, 2007 9:48 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Getting selectedItems to properly
*select*...



Got it!

It appears that selectedItems is dependent on the data being 
*absolutely identical* to the dataProvider. And while I thought my data 
was identical, it really wasn't. In the debugger, if you look at a 
variable, its always: Array (@123456). What I found was that although 
the data was definitely the same, that number was not.

To fix the problem, I centralized all data to go through one data 
manager, whereas before I was reinitializing a different data component 
in each component.

So now, I'm basically calling parentApplication.dataManager.someFunction
() from all of my components. This isn't good quite frankly, but by 
doing so, the @123456 is always the same.

If anyone else can think of a better way, I'm all ears... 



 


[flexcoders] Re: Getting selectedItems to properly *select*...

2007-03-14 Thread qnotemedia
--- In flexcoders@yahoogroups.com, Gordon Smith [EMAIL PROTECTED] wrote:
 If you want to set the selection based on data, you'll have to loop
 through all the items, inspect whether each item has the data you
 want, and select it if so.

I actually tried something like that.  But myGrid.selectedItems += item 
doesn't work.  What's the best practice way to push the item to 
selectedItems?



RE: [flexcoders] Re: Getting selectedItems to properly *select*...

2007-03-14 Thread Alex Harui
Arrays in Flex and Flash are not watched for changes.  After you mutate
the array you have to set it again.

 

var tmp:Array = myGrid.selectedItems

tmp += item;

myGrid.selectedItems = tmp;

 

If you see something that takes an ArrayCollection then it is watched
for changes.  IOW, the grid did not know you added an item to its
selectedItems array.

 

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of qnotemedia
Sent: Wednesday, March 14, 2007 4:27 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Getting selectedItems to properly
*select*...

 

--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, Gordon Smith [EMAIL PROTECTED] wrote:
 If you want to set the selection based on data, you'll have to loop
 through all the items, inspect whether each item has the data you
 want, and select it if so.

I actually tried something like that. But myGrid.selectedItems += item 
doesn't work. What's the best practice way to push the item to 
selectedItems?

 



[flexcoders] Re: Getting selectedItems to properly *select*...

2007-03-14 Thread qnotemedia
--- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote:

 Arrays in Flex and Flash are not watched for changes.  After
 you mutate the array you have to set it again.

 var tmp:Array = myGrid.selectedItems
 tmp += item;
 myGrid.selectedItems = tmp;

OK - I've retried specificaly what you've shown, and it still doesn't 
work.  I assigned a findItems() function to a temporary array, 
arTemp.  The function returns an Array of items found.  The very next 
line is myGrid.selectedItems = arTemp.

As mentioned in earlier posts, the items in this found array have 
precisely matched data to the dataProvider of the grid, and the 
selection still doesn't occur, without any errors either.  The *only* 
difference between the two is the @123456 following the Array 
description in the debugger.

At least I have something that works (three posts back), but now I'm 
running into a similar problem in another area of my app, and I'd 
like to move forward with this thread...


I have another popup with two grids.  Grid A has a multi-level 
ArrayCollection.  i.e.:
myAC[0].something
myAC[0].somethingElse
myAC[0].anotherAC[0].anotherSomething
myAC[0].anotherAC[1].anotherSomethingElse

myAC[1].something
...etc...

When the user clicks on Grid A (not multi-select), Grid B's 
selectedItems is populated with the second-level AC anotherAC, like 
this:

gridB.selectedItems = gridA.selectedItem.anotherAC.source


And it works!

BUT!!!  When I select another item and come back to the first one, 
the anotherAC level has disappeared without a trace!  It disappears 
from all bound ACs.

WTF?!  And BTW, I additionally tried the findItems() function as 
mentioned here.  The same problem happens in that nothing is selected.


Again, I've put together a gif to express my anxiety:
qnotemedia.com/dissapearing.gif

...this is a before and after shot.  On the left is before anything 
has been selected, and on the right, is immediately after a selection 
has occured.  On the right side, notice that the 
dgAllRoles.selectedItems is correctly populated, but that both the 
dgSelectedNames dataProvider AND the original AC, selectedDevTeam 
have had thei second tiered item collectedRoles completely 
dissapear.


Crossing my fingers that someone can understand this...
 - Chris



RE: [flexcoders] Re: Getting selectedItems to properly *select*...

2007-03-14 Thread Alex Harui
Internally, we're doing an instance check, not a test of properties to
see if they match.  Unless you've handed the list an array of things
that are the same instances as they are in the dataprovider it won't
match.

 

I can't get to the GIF for some reason.  Are you saying that myAC[0] was
modified so that the sub AC was removed?  I'd go find out what actually
got changed.

 

-Alex

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of qnotemedia
Sent: Wednesday, March 14, 2007 5:55 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Getting selectedItems to properly
*select*...

 

--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, Alex Harui [EMAIL PROTECTED] wrote:

 Arrays in Flex and Flash are not watched for changes. After
 you mutate the array you have to set it again.

 var tmp:Array = myGrid.selectedItems
 tmp += item;
 myGrid.selectedItems = tmp;

OK - I've retried specificaly what you've shown, and it still doesn't 
work. I assigned a findItems() function to a temporary array, 
arTemp. The function returns an Array of items found. The very next 
line is myGrid.selectedItems = arTemp.

As mentioned in earlier posts, the items in this found array have 
precisely matched data to the dataProvider of the grid, and the 
selection still doesn't occur, without any errors either. The *only* 
difference between the two is the @123456 following the Array 
description in the debugger.

At least I have something that works (three posts back), but now I'm 
running into a similar problem in another area of my app, and I'd 
like to move forward with this thread...

I have another popup with two grids. Grid A has a multi-level 
ArrayCollection. i.e.:
myAC[0].something
myAC[0].somethingElse
myAC[0].anotherAC[0].anotherSomething
myAC[0].anotherAC[1].anotherSomethingElse

myAC[1].something
...etc...

When the user clicks on Grid A (not multi-select), Grid B's 
selectedItems is populated with the second-level AC anotherAC, like 
this:

gridB.selectedItems = gridA.selectedItem.anotherAC.source

And it works!

BUT!!! When I select another item and come back to the first one, 
the anotherAC level has disappeared without a trace! It disappears 
from all bound ACs.

WTF?! And BTW, I additionally tried the findItems() function as 
mentioned here. The same problem happens in that nothing is selected.

Again, I've put together a gif to express my anxiety:
qnotemedia.com/dissapearing.gif

...this is a before and after shot. On the left is before anything 
has been selected, and on the right, is immediately after a selection 
has occured. On the right side, notice that the 
dgAllRoles.selectedItems is correctly populated, but that both the 
dgSelectedNames dataProvider AND the original AC, selectedDevTeam 
have had thei second tiered item collectedRoles completely 
dissapear.

Crossing my fingers that someone can understand this...
- Chris

 



RE: [flexcoders] Re: Getting selectedItems to properly *select*...

2007-03-14 Thread Gordon Smith
I assume you meant
 
tmp.push(item);
 
instead of
 
tmp += item;
 
Array doesn't support a += operator as far as I know.
 
- Gordon



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Alex Harui
Sent: Wednesday, March 14, 2007 4:33 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Re: Getting selectedItems to properly
*select*...



Arrays in Flex and Flash are not watched for changes.  After you mutate
the array you have to set it again.

var tmp:Array = myGrid.selectedItems

tmp += item;

myGrid.selectedItems = tmp;

If you see something that takes an ArrayCollection then it is watched
for changes.  IOW, the grid did not know you added an item to its
selectedItems array.



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of qnotemedia
Sent: Wednesday, March 14, 2007 4:27 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Getting selectedItems to properly
*select*...

--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, Gordon Smith [EMAIL PROTECTED] wrote:
 If you want to set the selection based on data, you'll have to loop
 through all the items, inspect whether each item has the data you
 want, and select it if so.

I actually tried something like that. But myGrid.selectedItems += item 
doesn't work. What's the best practice way to push the item to 
selectedItems?

 


[flexcoders] Re: Getting selectedItems to properly *select*...

2007-03-08 Thread qnotemedia
To truly express my frustration, I've put together this shot of some 
code:

qnotemedia.com / wontwork.gif

...note that in the above example, only arSecondSelection actually 
works.  The others select nothing.