Adobe Dreamweaver Forums



Last 10 THreads :         Load dynamic text into an embeded swf (Last Post : mikeyjray - Replies : 4 - Views : 9 )           »          Log email text (Last Post : Torgom - Replies : 0 - Views : 1 )           »          Properties > Flex Build Path (Last Post : kevxross - Replies : 0 - Views : 1 )           »          Can Anyone Help With Sub Menus (Last Post : Murray *ACE* - Replies : 8 - Views : 9 )           »          transferring DW license from crashed computer (Last Post : Sonjay - Replies : 1 - Views : 7 )           »          DIV in Table not working. (Last Post : Murray *ACE* - Replies : 13 - Views : 14 )           »          Variable for Loader Content (Last Post : Sea Crystal - Replies : 0 - Views : 1 )           »          left join won't work in query of query? (Last Post : Dan Bracuk - Replies : 5 - Views : 6 )           »          fireworks exports hundreds of files (Last Post : Rob Miller - Replies : 0 - Views : 1 )           »          Fireworks Color Selection Bug (Last Post : Linda Rathgeber - Replies : 3 - Views : 4 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Flex
 
Tags:



Reply
  #1 (permalink)  
Old 11-25-2008, 06:13 PM
tberg3db
 
Posts: n/a
Diggs:
Default Datagrid labelfunction timing

I have a dataGrid that uses a labelFunction for one of the columns to display a
text string instead of the foreign key integer. Most times the column text
does not display when the dataGrid is initially displayed, but will always
display after I update dataGrid's dataProvider. So I must have a timing
problem. The dataProvider for the dataGrid is an ArrayCollection that is
populated through an AMF remote object. This occurs initially using the
Application's 'creationComplete' event. I appreciate any ideas to help me
solve this issue.
Thanks,
Todd



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-25-2008, 07:04 PM
rtalton
 
Posts: n/a
Diggs:
Default Re: Datagrid labelfunction timing

Does the foreign key integer always display if you disable the labelFunction, or do you still get nothing?
Reply With Quote
  #3 (permalink)  
Old 11-25-2008, 07:33 PM
tberg3db
 
Posts: n/a
Diggs:
Default Re: Datagrid labelfunction timing

Yes, if I remove the labelFunction the integer is always displayed correctly.
Reply With Quote


  #4 (permalink)  
Old 11-25-2008, 08:03 PM
Amy Blankenship
 
Posts: n/a
Diggs:
Default Re: Datagrid labelfunction timing


"tberg3db" <webforumsuser@macromedia.com> wrote in message
news:gghem1$qes$1@forums.macromedia.com...
>I have a dataGrid that uses a labelFunction for one of the columns to
>display a
> text string instead of the foreign key integer. Most times the column
> text
> does not display when the dataGrid is initially displayed, but will always
> display after I update dataGrid's dataProvider. So I must have a timing
> problem. The dataProvider for the dataGrid is an ArrayCollection that is
> populated through an AMF remote object. This occurs initially using the
> Application's 'creationComplete' event. I appreciate any ideas to help
> me
> solve this issue.


Are you getting a collection change event on the ArrayCollection?


Reply With Quote
  #5 (permalink)  
Old 11-25-2008, 09:23 PM
tberg3db
 
Posts: n/a
Diggs:
Default Re: Datagrid labelfunction timing

Sorry, I didn't give much info. I've included relevant code now. When I put a
breakpoint in the labelFunction, the cAccountsDP ArrayCollection is empty at
the time the page is displayed. I have another function that updates the
dataGrid selectedItem values with formItem inputs. When that function is run,
the labelFunction gets fired again and now the cAccountsDP ArrayCollection is
populated and the column is displayed correctly.

<mx:Script>
<![CDATA[
[Bindable]
public var cAccountsDP:ArrayCollection;
[Bindable]
public var contactsDP:ArrayCollection;

// Application 'creationComplete' function
protected function ContactsInit():void
{
cAccountsDP = ActiveRecords.Accounts.findAll( );
contactsDP = ActiveRecords.Contacts.findAll( );
}

// Label Function to Display Account Name for Account_id
public function getAccountName(item:Object,columnataGridColumn): String
{
var tAccount_name: String = "";
for (var i:int=0;i<cAccountsDP.length;i++){
var tAccount_id:int = cAccountsDP[i].Account_id;
if(item.Account_id == tAccount_id){
tAccount_name = cAccountsDP[i].Account_name;
break;
}
}
return tAccount_name;
}
// function to update dataGrid with new form values
public function OnSave():void
{
if(contactEditAccount.selectedItem) contactsDG.selectedItem.Account =
contactEditAccount.selectedItem.Account_id;
}
]]>
</mx:Script>
<mxataGrid id="contactsDG" dataProvider="{contactsDP}">
<mx:columns>
<mxataGridColumn
headerText="Account"
dataField="Account_id"
labelFunction="getAccountName" />
</mx:columns>
</mxataGrid>

Reply With Quote
  #6 (permalink)  
Old 11-25-2008, 09:42 PM
Amy Blankenship
 
Posts: n/a
Diggs:
Default Re: Datagrid labelfunction timing


"tberg3db" <webforumsuser@macromedia.com> wrote in message
news:gghq1v$b8e$1@forums.macromedia.com...
> Sorry, I didn't give much info. I've included relevant code now. When I
> put a
> breakpoint in the labelFunction, the cAccountsDP ArrayCollection is empty
> at
> the time the page is displayed. I have another function that updates the
> dataGrid selectedItem values with formItem inputs. When that function is
> run,
> the labelFunction gets fired again and now the cAccountsDP ArrayCollection
> is
> populated and the column is displayed correctly.
>
> <mx:Script>
> <![CDATA[
> [Bindable]
> public var cAccountsDP:ArrayCollection;
> [Bindable]
> public var contactsDP:ArrayCollection;
>
> // Application 'creationComplete' function
> protected function ContactsInit():void
> {
> cAccountsDP = ActiveRecords.Accounts.findAll( );
> contactsDP = ActiveRecords.Contacts.findAll( );
> }


before your closing bracket just above, put this:

cAccountsDP.addEventListener(CollectionEvent.COLLE CTION_CHANGE,
changeHandler);
contactsDP..addEventListener(CollectionEvent.COLLE CTION_CHANGE,
changeHandler);

then add this somewhere in your code

private function changeHandler(e:CollectionEvent):void {
//put break point here
}

Does the event fire for either collection?

Hope this clarifies;

Amy


Reply With Quote


  #7 (permalink)  
Old 11-25-2008, 10:23 PM
tberg3db
 
Posts: n/a
Diggs:
Default Re: Datagrid labelfunction timing

Stepping through the breakpoints, the event fires first for the contactsDP, then for the labelFunction, then for the cAccountsDP.
Reply With Quote
  #8 (permalink)  
Old 11-26-2008, 02:04 AM
Amy Blankenship
 
Posts: n/a
Diggs:
Default Re: Datagrid labelfunction timing


"tberg3db" <webforumsuser@macromedia.com> wrote in message
news:gghtov$fq0$1@forums.macromedia.com...
> Stepping through the breakpoints, the event fires first for the
> contactsDP, then for the labelFunction, then for the cAccountsDP.


Try setting the dp in the collection change handler instead of setting it
before the collection has arrived, using a temp var if necessary.

HTH;

Amy


Reply With Quote
  #9 (permalink)  
Old 12-01-2008, 09:33 PM
tberg3db
 
Posts: n/a
Diggs:
Default Re: Datagrid labelfunction timing

The solution I found was to use the dataGrid's preinitialize event to set the dataProvider for the column labels.
Todd
Reply With Quote


  #10 (permalink)  
Old 12-01-2008, 09:53 PM
rtalton
 
Posts: n/a
Diggs:
Default Re: Datagrid labelfunction timing

You don't mention if you did this, but might also check into using a result handler on the remote object to assign the dataprovider to the Data Grid.
Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 11:15 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Cheap Car Insurance - Compare Motor Insurance
Endsleigh Car Insurance Natwest Car Insurance
More Than Car Insurance Norwich Union Car Insurance
Prudential Car Insurance Zurich Car Insurance
Inactive Reminders By Mished.co.uk