![]() |
![]() |
||||||
|
|||||||
| Tags: |
![]() |
|
|||
|
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 |
| Sponsored Links |
|
|||
|
"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? |
|
|||
|
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,column ataGridColumn): 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> <mx ataGrid id="contactsDG" dataProvider="{contactsDP}"><mx:columns> <mx ataGridColumnheaderText="Account" dataField="Account_id" labelFunction="getAccountName" /> </mx:columns> </mx ataGrid> |
|
|||
|
"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 |
|
|||
|
"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 |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
- Contact Us
-|-
Adobe Dreamweaver Forums -|-
Archive -|-
Top -|-Rules/Disclaimer-|-Help/Support-|-Advertise