4 Replies Latest reply on Apr 7, 2010 7:56 AM by GeorgeWS

    Combobox to combobox

    GeorgeWS Level 1

      I have a combobox filled by an arraycollection from a RO. I have a second Combobox filled from a similar arraycollection. How can I get the first combo to filter the 2nd. I can filter a grid no problem but when it comes down to the filterFunction I do not know what to make my filters equal to.

       

      public function accFilterFunction(item:Object):Boolean {

      if (accfilter.selectedItem.label == ? ){

      return true;

      } else{

      return false

      }}

       

      Im not sure about the item part of the first line maybe this only applies to datagrids? Also where the ? is I dont know what id be setting the accfilter (my first combobox id) to. Any thoughts, code help

       

      Thanks

       

      George

        • 1. Re: Combobox to combobox
          SpaghettiCoder Level 3

          private function filter():void

          {

               arrayCollection.filterFunction = applyFilter;

               arrayCollection.refresh();

          }

           

           

          private function applyFilter(item:Object):Boolean

          {

               if ( )

               {

                    return true;

               }

               else

               {

                    return item.columnName == someVariable;

               }

          }

          • 2. Re: Combobox to combobox
            GeorgeWS Level 1

            No...

             

            This is very close im sure:

             

            public function aacFilterFunc(item::Object):Boolean {

                 if (accfilter.selectedItem.label == myDisplay.getItemAt()) {

            return true;

            { else {

            return false;

            }

             

            I dont know what this should be? myDisplay.getItemAt()

            if I make it myDisplay.getItemAt(0) and I pick "Ralphs" from accfilter combobox it works. Ralphs happens to be in the first row of my data.

             

            accfilter is the id of my first ComboBox

             

            How do I get the list of the data items in the MyDisplay arrayCollection?

             

            I would think something easy like: myDisplay.getItemAt(data); but I can tell thats to easy sheesh there are only 2 fields, data and label

             

            Flex sucks when it comes to combobox

            • 3. Re: Combobox to combobox
              SpaghettiCoder Level 3

              You have two combo boxes right?

               

              combobox 1, combobox2,

               

              when you select something in combobox1 it filters the available contents of combobox2???

               

              is that what you're trying to do?

              • 4. Re: Combobox to combobox
                GeorgeWS Level 1

                Got it, wow and it was easier than I thought

                 

                public function aacFilterFunc(item::Object):Boolean {

                     if (accfilter.selectedItem.label == item.data) {

                return true;

                { else {

                return false;

                }

                 

                Thanks