1 Reply Latest reply on Jun 9, 2007 10:36 AM by BLXWebMaster

    two comboBoxes

    Level 7
      Hi All,
      I have to comboBoxes, one with my customers name and the second with the
      contacts. But I want the contacts automatic update when I change a customer
      name.
      Any sample or link ?
      Please advice.... thanks

      JFB


        • 1. Re: two comboBoxes
          BLXWebMaster Level 1
          I am assuming that your contact are an ArrayCollection. If so, you can accomplish it by using a filterFunction..

          It would be easier if you posted your code, however you should be able to figure it out.

          Here is a snippet.
          Basically you have an onChange event "arContacts.refresh(); on your Customer cobo box. This will force the filterFunction to check what you selected and filter the contacts based on the CustomerName field which should be in your array for the contacts.

          Also, I suggest adding collection change listener on the arContacts. This way you can also reset the contact combo box to the first index. If you do not, it tends to keep highlghted the previous selected item even though it is no longer in the filtered array.

          [Bindable]
          private var arContacts:ArrayCollection = null;
          private function getLookupCCReceived(event:ResultEvent):void {
          arContacts= new ArrayCollection();
          arContacts = event.result as ArrayCollection;
          arContacts.addEventListener(CollectionEvent.COLLECTION_CHANGE,ContactChanged);
          arContacts.filterFunction=processCCFilter;
          }

          // Filter function
          public function processCCFilter(item:Object):Boolean {
          var result:Boolean=false;
          if ((cbCustomer.selectedLabel == 'Select Customer Name' || (item.Type != null && item.Customer.toUpperCase().indexOf(cbCustomer.selectedLabel.toUpperCase()) >= 0))
          )
          result=true;
          return result;
          }

          private function ContactChanged(evt:CollectionEvent = null):void{
          cbContacts.selectedIndex = 0;
          }