3 Replies Latest reply on Jul 10, 2008 2:07 AM by chris00chris

    Dynamically Changing ComboBox

    chris00chris Level 1

      I'm putting together a custom control which is to be an "auto-complete" text box, kind of like the Firefox URL bar. I've derived from a standard editable ComboBox and the control pretty much works.

      Obviously as the user types into the text box I want to dynamically modify the drop down list box to contain the auto-complete text. This is easy enough, however my problem is that whenever I add items to the list box I find that the drop down box rolls up and then back down again. If I remove items this does not happen. My desired functionality is that the drop down list box can be modified without it rolling up and down.

      The dataProvider of the ComboBox is currently bound to an ArrayCollection and I am adding and removing single items to and from that collection.

      I get the impression this may be something to do with how the dataProvider works, but I'm not sure.

      Help is very much appreciated.

        • 1. Re: Dynamically Changing ComboBox
          Rob Rusher
          Not to burst your bubble, but I think that component already exist.

          In fact, a few have been posted on the exchange: http://www.adobe.com/cfusion/exchange/index.cfm?searchfield=autocomplete&search_exchange=& num=25&startnum=1&event=search&sort=0&Submit=

          If you are doing it so that you learn how, I'd need to see the code. Post it on a url with the source if you can.
          • 2. Re: Dynamically Changing ComboBox
            chris00chris Level 1
            Don't worry, my bubble is not burst! I did look at some of that code for some ideas, but then wanted to try to do it myself for (as you said) a learning experience. Also I wanted to customise my control a bit, for example I want to complete where any option text is a substring, rather than just "begins with" the typed text. I hadn't actually tried out those components you suggested, but I've just done so now and... the one I tried suffers from the same problem! (This is the control entitled "Adobe AutoComplete Input"). They have increased the scroll speed so it's not as obvious, but nevertheless, it still has the problem.

            Anyway, here's my source code. Bear in mind I've only just started using Flex, so it may well be a load of rubbish! Please note that it matches on substrings, not "begins with" strings. It also inserts and removes from the option list whilst maintaining alplabetical order (this insert/remove may be unnecessary though). It contains a pre-setup list of complete strings so you can just embed it directly into a simple test app and you should be able to see it working.

            As I said, I expect this is something to do with dataProvider binding, but I'm not sure...

            It would be great if you could take a look and let me know if you have any suggestions.


            • 3. Re: Dynamically Changing ComboBox
              chris00chris Level 1
              Just a quick note: To test it, run the app then just type "aaa" into the box. The list scrolls up and down each time you type "a" (as items are removed from the complete list). Then delete the "a"s one at a time and see how the list does not scroll up and down (as items are added to the complete list).