Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Flex > Flex 2, 3 & 4

Reply
 
Thread Tools Rate Thread Display Modes
Old 08-10-2006, 12:45 AM   #1
Elsa
Registered User
 
Join Date: Jul 2006
Posts: 5
Question Help with DataGrid, Events and selectedItem and loose coupling

I'm pretty new to Flex, but I know this must be possible, however search as I might I can't find any examples of what I need online, so I'm hoping someone here can help me out, or point me in the right direction.

I've got two custom components, one with a DataGrid that has an ArrayCollection as it's dataprovider, and the other is a simple panel - just meant for displaying further details of whatever item is selected in the datagrid.

How can I pass the selectedItem from the DataGrid across to the panel component? At the moment I can't seem to pass it outside of the datagrid component, perhaps because I'm not using the right Event or because I'm not binding it properly.

Thanks,
Elsa
Elsa is offline   Reply With Quote
Old 08-10-2006, 10:24 AM   #2
Elsa
Registered User
 
Join Date: Jul 2006
Posts: 5
Default

Ok I'll add some code as the lack of responses suggests that I'm not making the problem very clear.

Here is the function I'm trying to create to pass the selectedItem data up to the Application:
Code:
private function selectHandler():void
{
var event:Event = new Event("movieSelect");
event = listItems.selectedItem

//event.target.selectedItem = listItems.selectedItem;
dispatchEvent(event);
}
Elsa is offline   Reply With Quote
Old 08-10-2006, 11:10 AM   #3
Tink
Addict
 
Tink's Avatar
 
Join Date: Nov 2001
Location: London
Posts: 2,128
Default

hmm i'm really not sure what you up to here

//first you create an Event and store it in the var 'event'
var event:Event = new Event("movieSelect");

//now you try and set the var event to a integer
event = listItems.selectedItem

//now you try to dispatch the integer
dispatchEvent(event);
Tink is offline   Reply With Quote
Old 08-10-2006, 01:27 PM   #4
Elsa
Registered User
 
Join Date: Jul 2006
Posts: 5
Default

I'm calling the function at from the datagrid change="selectHandler()"

It seems easy enough to pass selectedItem to down a child component, but both my componenets are sat in the Application, so I need to pass the selectedItem up to the Application first.

Is selectedItem an int? I know selectedIndex is but I thought selectedItem was a Object that captures the selected item so you could refer to it, in the same way as you would the array e.g.

datagridID.selectedItem.fieldyouwant

Thanks.
Elsa is offline   Reply With Quote
Old 08-10-2006, 01:50 PM   #5
Tink
Addict
 
Tink's Avatar
 
Join Date: Nov 2001
Location: London
Posts: 2,128
Default

Quote:
Is selectedItem an int? I know selectedIndex is but I thought selectedItem was a Object that captures the selected item so you could refer to it, in the same way as you would the array e.g.
sorry yes its an Object, it aint and Event object though, so u can't dispatch it like that.

Can u paste all your code so we can actually see what your doing?

Last edited by Tink; 08-10-2006 at 01:52 PM.
Tink is offline   Reply With Quote
Old 08-10-2006, 05:52 PM   #6
Elsa
Registered User
 
Join Date: Jul 2006
Posts: 5
Default ok you asked for it :) ....

Peter Ent from Adobe has rescued me....

Adobe Forums

But thanks Tink I appreciate you looking.

Last edited by Elsa; 08-10-2006 at 06:17 PM.
Elsa is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:37 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.