6 Replies Latest reply on Jul 4, 2009 9:58 AM by 435.mahesh

    problem due to ArrayCollection?

    435.mahesh Level 1


      Here is my code

      <mx:ArrayCollection id="cmbdata">        
              <mx:Object data="1" label="yes"/>
              <mx:Object data="0" label="no"/>

      Here i am displying ArrayList data into combobox


      <mx:FormItem label="Vendor Active?">
                      <mx:ComboBox width="104" id="vendoractive" prompt="Select" dataProvider="{cmbdata}" textAlign="left" />                   


      Here i am displaying selected value in datagrid




      <mx:DataGridColumn width="100"  textAlign="center" headerText="Active" dataField="vendorActive" />


      </...>                                                                                                    vendorActive will property name in the Valueobject(value come from  database)



      My requirement is

      in first i am showing yes,no in combobox to end user.

      When he selected yes,then corresponding value(1) will be stored into database.

      When i am diplaying in datagrid "yes" will be displayed.

      Here i am facing the problem,while storing 1 will be stored into database,but unable to show "yes" in the datagrid



      D.Mahesh babu

        • 1. Re: problem due to ArrayCollection?
          *Prashant Shelke* Level 4

          Your requirement is not so clear. But according to my understanding, On change of combo you need to show Yes in Active column for all of rows,

          one way is you need to iterate dataGrid's dataProvider & set dataGrid.dataProvider.getItemAt(cnt).vendorActive = combo.selectedItem.label; & I thinks storing this information per row will be redundant.

          • 2. Re: problem due to ArrayCollection?
            rgadiparthi Level 2

            Once you retrieve from database you have to process your data provider, to show 'yes' when you get 1 and then pass that data to your data grid.



            • 3. Re: problem due to ArrayCollection?
              Ansury Level 3

              I'm not certain I'm interpreting your question correctly either, but I think might looking for labelFunction, which would let you display a "Yes" or "No" in the datagrid while the actual data is a 1 or a 0.

              • 4. Re: problem due to ArrayCollection?
                Ansury Level 3



                private function vendorActiveLabel(item:Object,column:DataGridColumn):String
                  if (item.vendorActive == 1)

                     return "Yes";


                     return "No".





                <mx:DataGridColumn width="100"  textAlign="center" headerText="Active" labelFunction="vendorActiveLabel" />



                • 5. Re: problem due to ArrayCollection?
                  435.mahesh Level 1

                  Thanq.How it is doing for combobox?





                  D.Mahesh babu

                  • 6. Re: problem due to ArrayCollection?
                    Ansury Level 3

                    How do you customize what a combobox shows when you provide it a list of objects?


                    Inside the ComboBox mxml tag you could use:



                    (replace label with the name of the field containing the data you want to display)


                    Or for more complex requirements (say you want to interpret the data and display some other text to the user that isn't in the data):



                    (works the same way as the datagrid labelFunction, you'd need to write a label function)



                    In your case for the ComboBox, I think you would want to use labelField="label" because for a dataProvider you're giving a list of objects with a "label" property that contains the strings you want to display.