8 Replies Latest reply on Aug 28, 2009 8:53 AM by ahrimanes6x3

    Combobox with multiple columns

    Zolotoj Level 3

      Is it possible to make a combobox with two columns in the dropdown area?

       

      Thanks

        • 1. Re: Combobox with multiple columns
          Flex harUI Adobe Employee

          Use a DataGrid instead of a List

           

          Alex Harui

          Flex SDK Developer

          Adobe Systems Inc.

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

          • 2. Re: Combobox with multiple columns
            Zolotoj Level 3

            As what? As a dropdown?

            • 3. Re: Combobox with multiple columns
              bcnice Level 1

              What is you did something like this - set the labelFunction on the comboBox so you could grab two different fields from your dataprovider and simulate two columns?

               

                    <mx:Script>
                  <![CDATA[
                      private function showTwoColumns(rowItem:Object):String
                      {
                          return rowItem.code+"\t"+rowItem.description;
                      }
                  ]]>
                  </mx:Script>

               

                  <mx:ComboBox width="200" labelFunction="showTwoColumns">
                      <mx:dataProvider>
                              <mx:Object code="AL" description="Alabama"/>
                              <mx:Object code="AK" description="Alaska"/>
                              <mx:Object code="AZ" description="Arizona"/>
                              <mx:Object code="AR" description="Arkansas"/>
                      </mx:dataProvider>
                  </mx:ComboBox>

               

              Brian

              • 4. Re: Combobox with multiple columns
                Zolotoj Level 3

                It does not show two columns. It puts two fields into one string.

                • 5. Re: Combobox with multiple columns
                  ahrimanes6x3 Level 1

                  make your own componen to show 2 colums... and assig it to combo box as itemrenderer...

                   

                  twoColums.mxml:

                   

                  <?xml version="1.0" encoding="utf-8"?>
                  <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"
                      horizontalScrollPolicy="off" >
                      <mx:Text text="{data.Column1}" width="93">
                      </mx:Text>
                      <mx:Text text="{data.Column2}">
                      </mx:Text>
                  </mx:HBox>

                   

                  in your main app or another custom conponen place your combobox like thi:

                   

                      <mx:ComboBox id="myCB" dataProvider="{yourdata}" labelField="Column1"
                          itemRenderer = "components.twoColums">
                      </mx:ComboBox>

                   

                  mybe you need to add width and dropdowwidth properties to show the items in a good way....hope this work..

                   

                  PD. this works the same for Adobe autocomplete.. as autocomplete is a component heritated from combobox..:

                   

                  make  shure you have included  the autocomplete component in your project at its says in the readme file included by Adobe then..

                   

                      <Adobe:AutoComplete id="myCB" arrowButtonWidth = "30" dataProvider="{yourdata}" labelField="Column1"
                          itemRenderer = "components.twoColums">
                      </Adobe:AutoComplete>

                   

                  note the arrowButtonWidth if you dont put this property the autocomplete will just show as a common text field...

                  remember auto complete will have some issues with the itemrenderer stuff.. if you wirite too fast, the first character you write will be lost, so calmd down,  im traing to figure out how to soleve that issue...

                   

                  haaaa by the way if you already have another way to show 2 columns please telme how you solve it...

                  • 6. Re: Combobox with multiple columns
                    Zolotoj Level 3

                    Yeah, that might work.

                    How can I make the dropdown portion wider than ComboBox itself?

                    • 7. Re: Combobox with multiple columns
                      flex2008 Level 3

                      use the dropdownwidth property

                      • 8. Re: Combobox with multiple columns
                        ahrimanes6x3 Level 1

                        haaa . o dont know hohat, in fact im a beginer :P sorry.

                         

                         

                        Date: Thu, 27 Aug 2009 12:57:59 -0600

                        From: forums@adobe.com

                        To: ahrimanes_6x3@hotmail.com

                        Subject: Combobox with multiple columns

                         

                        Yeah, that might work.

                        How can I make the dropdown portion wider than ComboBox itself?

                        >