15 Replies Latest reply on Jun 4, 2009 6:20 PM by Michael Borbor

    Pass ArrayCollection to ItemEditor ComboBox

    ssmacwilliams

      I need to pass the Arraycollection to an ItemEditor ComboBox. I thought this would be a simple process, but after all the posts I have read it doesn't look to be. I would like a solid understanding, because I think this is probably the same my Checkbox says [Object object] after I click the checkbox.

      Thanks in advance.

       

      ERROR: 1120: Access of undefined property Borrowers.

       

      Scenario:

      RemoteObject passes back the query from the CFC to my handler....I know that because I see this in the debug mode and if I move the ComboBox out of the DataGrid it populates.

       

      MXML file

        <mx:Script>
         <![CDATA[

          import mx.controls.Alert;
          import mx.rpc.events.FaultEvent;
          import mx.collections.ArrayCollection;
          import mx.rpc.events.ResultEvent;
         
          [Bindable]
          private var Borrowers:ArrayCollection;
           
          private function initComp():void
           { transp.getUsers(); }
          
          //RemoteObject alert meesage
                  private function serverFault(event:FaultEvent):void
                       {  Alert.show(event.fault.faultString,'Server Error'); } 
                       
          private function getUsers_Handler(event:ResultEvent):void
           { Borrowers = event.result as ArrayCollection; }
             
         ]]>
        </mx:Script>

       

      <mx:Panel>

          <mx:TabNavigator>

           <mx:Form>

                    <mx:DataGrid>

                          ...

       

       

       

       

       

       

                               <mx:DataGridColumn headerText="Borrower" dataField="BORROWER" editorDataField="selectedItem" id="grdBorrower">

       

       

       

       

                                    <mx:itemEditor>

       

       

       

       

                                    <mx:Component>

       

       

       

       

                                         <mx:ComboBox dataProvider="{Borrowers}"/>

       

       

       

       

                                    </mx:Component>

       

       

       

       

                                    </mx:itemEditor>

       

       

       

       

       

                               </mx:DataGridColumn>

       

       

                    </mx:DataGrid>

          </mx:Form>    

      </mx:TabNavigator>

      </mx:Panel>

        • 1. Re: Pass ArrayCollection to ItemEditor ComboBox
          Michael Borbor Level 4

          When you place a component as an itemEditor or itemRenderer the scope of this controls is outside the current scope in your case you need to change the dataProvider for you combobox to {data} . and set the labelField="BORROWER".  Data is an special property that the controls pass to the itemRenderers or itemEditors

          • 2. Re: Pass ArrayCollection to ItemEditor ComboBox
            ssmacwilliams Level 1

            Sorry about this but I failed to mention that the combobox comes from a totaly seperate dataprovider than the datagrid. How does the ComboBox get the ArrayCollection from the other "resultset"?

             

            When I made your suggestions to the code. It did put the data into the ComboBox, but the other selections were not available...assumed it needs to point to the correct datagrid.

            • 3. Re: Pass ArrayCollection to ItemEditor ComboBox
              ssmacwilliams Level 1

              I also forgot to mention that after you click the ComboBox it changes the current selection to [Object object].

              • 4. Re: Pass ArrayCollection to ItemEditor ComboBox
                Michael Borbor Level 4

                Oh I see just prepend outerDocument.

                 

                outerDocument.yourDataProvider.

                • 5. Re: Pass ArrayCollection to ItemEditor ComboBox
                  ssmacwilliams Level 1

                  When I replace it with :

                   

                  <mx:Component><mx:ComboBoxdataProvider="{outerDocument.Borrowers}" labelField="BORROWER"/> 

                  then I get an error:

                  1178: Attempted access of inaccessible property Borrowers through a reference with static type components.forms:TransactionPnl.</mx:Component

                  • 6. Re: Pass ArrayCollection to ItemEditor ComboBox
                    Michael Borbor Level 4

                    In order to avoid making wrong assumptions could you post or attach your

                    code?

                    • 9. Re: Pass ArrayCollection to ItemEditor ComboBox
                      ssmacwilliams Level 1

                      Sorry, I replied via email and it must of taken them off.... here they are again

                      • 10. Re: Pass ArrayCollection to ItemEditor ComboBox
                        Flex harUI Adobe Employee

                        I just recently learned that you can't use a sequence of '-' to delineate code in these posts.  The mailer thinks that is the end of the message and truncates everything.  I tried '=' and it allowed it

                         

                        Alex Harui

                        Flex SDK Developer

                        Adobe Systems Inc.

                        Blog: http://blogs.adobe.com/aharui

                        • 11. Re: Pass ArrayCollection to ItemEditor ComboBox
                          ssmacwilliams Level 1

                          Thanks Alex, I didn't know that either.

                            I took out the '-' off from the attachments and have replaced them with '=' and submitted again.

                          • 12. Re: Pass ArrayCollection to ItemEditor ComboBox
                            ssmacwilliams Level 1

                            It doesn't seem to like that attachments so I have put full code in Post.  The main component that loads this one I would have to attach for it is to large.  Sorry...

                             

                            TransactionPnl.mxml

                            <?xml version="1.0" encoding="utf-8"?>
                            <mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" layout="absolute" title="Check-In / Check-Out Trancactions" creationComplete="initComp()">
                              <mx:Script>
                               <![CDATA[

                                import mx.controls.Alert;
                                import mx.rpc.events.FaultEvent;
                                import mx.collections.ArrayCollection;
                                import mx.rpc.events.ResultEvent;
                               
                                [Bindable]
                                private var Borrowers:ArrayCollection;
                                 
                                private function initComp():void
                                      { transp.getUsers(); }
                                
                                //RemoteObject alert meesage
                                private function serverFault(event:FaultEvent):void

                                      { Alert.show(event.fault.faultString,'Server Error'); } 
                                             
                                private function getUsers_Handler(event:ResultEvent):void
                                 { Borrowers = event.result as ArrayCollection; }
                                   
                               ]]>
                              </mx:Script>

                              <mx:RemoteObject id="transp" destination="ColdFusion" source="RMS.cfcs.RMS" showBusyCursor="true">
                               <mx:method name="getUsers" result="getUsers_Handler(event)" fault="serverFault(event)" />
                              </mx:RemoteObject>
                               
                               <mx:TabNavigator x="0" y="10" width="704" height="549" creationPolicy="all" id="tgNav" >
                                <mx:Canvas label="Demographic Info." width="100%" height="100%">
                                 <mx:Form x="10" y="10">
                                  <mx:FormItem label="Child's Last Name:">
                                   <mx:TextInput id="TransCLNAME"/>
                                  </mx:FormItem>
                                  <mx:FormItem label="Child's First Name:">
                                   <mx:TextInput id="TransCFNAME"/>
                                  </mx:FormItem>
                                  <mx:FormItem label="Mother's Last Name:">
                                   <mx:TextInput id="TransMLNAME"/>
                                  </mx:FormItem>
                                  <mx:FormItem label="Mother's First Name:">
                                   <mx:TextInput id="TransMFNAME"/>
                                  </mx:FormItem>
                                  <mx:FormItem label="Court Case #:">
                                   <mx:TextInput id="TransCC"/>
                                  </mx:FormItem>
                                  <mx:FormItem label="FSFN #:">
                                   <mx:TextInput id="TransFSFN"/>
                                  </mx:FormItem>
                                  <mx:FormItem label="Date Case Opened:">
                                   <mx:DateField id="TransCOpened"/>
                                  </mx:FormItem>
                                  <mx:FormItem label="Date Case Closed:">
                                   <mx:DateField id="TransCClosed"/>
                                  </mx:FormItem>
                                  <mx:FormItem>
                                   <mx:Button label="Update" width="90"/>
                                  </mx:FormItem>
                                 </mx:Form>
                                </mx:Canvas>
                                  
                                <mx:Canvas label="Check-In Out" width="100%" height="100%">
                                 <mx:Form x="10" y="10" width="100%" height="100%">
                                  <mx:FormItem label="Current Volumes:" height="80%">
                                   <mx:DataGrid id="gridVolumes" height="100%" editable="true">
                                    <mx:columns>
                                     <mx:DataGridColumn headerText="Volume No." dataField="VOLUME_NUM" id="grdVolNum" editable="false"/>
                                     <mx:DataGridColumn headerText="Type" dataField="V_TYPE_NAME" id="grdType" editable="false"/>
                                     <mx:DataGridColumn headerText="Status" dataField="CHKSTATUS" id="grdStatus">
                                               <mx:itemRenderer>
                                                   <mx:Component>
                                                           <mx:HBox horizontalAlign="center"><mx:CheckBox  selected="{data}" /></mx:HBox>
                                                   </mx:Component>
                                               </mx:itemRenderer>             
                                     </mx:DataGridColumn>
                                     <mx:DataGridColumn headerText="Barcode" dataField="BARCODE" textAlign="center" id="grdBarcode" editable="false"/>
                                     <mx:DataGridColumn headerText="Borrower" dataField="BORROWER" editorDataField="selectedItem" id="grdBorrower">
                                      <mx:itemEditor>
                                      <mx:Component>
                                       <mx:ComboBox dataProvider="{outerDocument.Borrowers}" labelField="BORROWER"/>
                                      </mx:Component>
                                      </mx:itemEditor>        
                                     </mx:DataGridColumn>                  
                                     <mx:DataGridColumn headerText="Client ID" dataField="CLIENT_ID" visible="false" id="grdClient"/>
                                    </mx:columns>
                                   </mx:DataGrid>
                                  </mx:FormItem>
                                  <mx:FormItem label="Volume Check Out By:">
                                   <mx:ComboBox></mx:ComboBox>
                                  </mx:FormItem>
                                  <mx:FormItem>
                                   <mx:Button label="Process Volumes"/>
                                  </mx:FormItem>
                                 </mx:Form>
                                </mx:Canvas>
                               </mx:TabNavigator>
                            </mx:Panel>

                            • 13. Re: Pass ArrayCollection to ItemEditor ComboBox
                              Michael Borbor Level 4

                              Have you traced Borrowers to see if it's getting filled?

                              • 14. Re: Pass ArrayCollection to ItemEditor ComboBox
                                ssmacwilliams Level 1

                                Yes, when I placed the trace inside the getUsers_Handler(). I could see that it was getting filled, but inorder to check this I had to make Borrowers public NOT private.  I was not able to compile when private because I received the following error:

                                 

                                1178: Attempted access of inaccessible property Borrowers through a reference with static type components.forms:TransactionPnl.

                                 

                                 

                                • 15. Re: Pass ArrayCollection to ItemEditor ComboBox
                                  Michael Borbor Level 4

                                  yes I forgot to mention that you need to make a property public if you want to access it from a itemEditor.

                                   

                                  I hope you're doing ok.