Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8237077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:21:03+00:00 2026-06-07T19:21:03+00:00

I have a ComboBox and the data provider is an ArrayCollection of 3 values:

  • 0

I have a ComboBox and the data provider is an ArrayCollection of 3 values: CA – California, NY – New York, TX – Texas. With the default behavior when I start typing in the ComboBox it will try to match the value from the beginning of the string, so if I start Typing TX it will bring up TX – Texas.

I want to be able to search at any part of the string and not just from the beginning, so if I type “xas” it will filter out the selection and only show TX – Texas. There is a very helpful post in the Adobe forums here on how to do this by changing the filter function on the ArrayCollection which provides data for the ComboBox and I have adapted it but I am having a slight issue with it.

If a user selects a value and then tries to enter in new text the first letter typed in the ComboBox does not show up.

1) Select the value CA – California in the ComboBox
2) Highlight the text and hit “n” on your keyboard
3) You would expect to see the textbox populated with “n” but the textbox remains empty

What could be causing this issue? It only happens if you already have a value selected. If you start with a blank ComboBox it works as expected.

<fx:Script>
    <![CDATA[
        import mx.collections.ArrayCollection;
        import mx.events.FlexEvent;

        import spark.events.TextOperationEvent;

        [Bindable]
        public var arrC:ArrayCollection = new ArrayCollection([{label:'CA - California'},{label:'NY - New York'},{label:'TX - Texas'}]);

        private function changeHandler(e:*):void
        {
            if (arrC.filterFunction != doFilter)
                arrC.filterFunction = doFilter;
            arrC.refresh();
        }

        private function doFilter(item:Object):Boolean
        {
            if(String(item.label).toLowerCase().indexOf(cb.textInput.text.slice(0 ,cb.textInput.selectionAnchorPosition).toLowerCase())>-1)             
            {
                return true;
            }
            return false;
        }                       

        protected function application1_creationCompleteHandler(event:FlexEvent):void
        {
            cb.textInput.addEventListener(TextOperationEvent.CHANGE,changeHandler );
        }

    ]]>
</fx:Script>

<s:ComboBox id="cb" dataProvider="{arrC}"/>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T19:21:05+00:00Added an answer on June 7, 2026 at 7:21 pm

    Got a solution for your problem (because I had to work out a custom component behaving similar to the googles search input box). Seems the normal input processing gets into wrong ways by filtering the dataprovider. However I didnt examined the sources of the unexpected behaviour as deeply as needed to provide a solide explanation of the causing problem (the idea of a possible solution came too fast ;.)). Here it is:

    <?xml version="1.0" encoding="utf-8"?>
    <s:ComboBox xmlns:fx="http://ns.adobe.com/mxml/2009" 
            xmlns:s="library://ns.adobe.com/flex/spark" 
            xmlns:mx="library://ns.adobe.com/flex/mx"
            skinClass="CGoogleComboSkin">
    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.collections.IList;
    
            import spark.events.TextOperationEvent;
    
            private var unfilteredDataProvider : IList;
            override public function set dataProvider(value:IList):void {
                super.dataProvider = value;
    
                unfilteredDataProvider = value;
            }
    
            override protected function textInput_changeHandler(
                    event:TextOperationEvent):void {
                super.textInput_changeHandler(event);
    
                if (unfilteredDataProvider is ArrayCollection) {
                    ArrayCollection(unfilteredDataProvider).filterFunction = filterMatches;
                    ArrayCollection(unfilteredDataProvider).refresh();
    
                    super.dataProvider = new ArrayCollection(unfilteredDataProvider.toArray()); 
                }
            }
    
            protected function filterMatches(item:Object):Boolean {
                if (item is String) {
                    if(String(item).toLowerCase().indexOf(
                        textInput.text.slice(0,
                            textInput.selectionAnchorPosition).toLowerCase())>-1)
                        return true;
                }
                else if (labelField && labelField!= "") {
                    if(item.hasOwnProperty(labelField) && 
                            String(item[labelField]).toLowerCase().indexOf(
                            textInput.text.slice(0,
                            textInput.selectionAnchorPosition).toLowerCase())>-1)
                        return true;
                }
    
                return false;
            }
        ]]>
    </fx:Script>
    <fx:Declarations>
    </fx:Declarations>
    

    The idea behind this solution was to construct the custom Combobox by inheritance and overriding the setter of the dataprovider in a way to have the unfiltered dataprovider as unchanged source by any textoperation but let the flex combobox deal in its usual way with a collection where no filter is attached to (which is by any input allready the result of the filtering of the source collection). It was just a try but worked and was as fast applicable as I appreciated it ;.)

    happy coding

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using editable combobox for my application. Combobox have default behavior like If
I have a combobox that is filled with data field JobCode from database. There
I have a JSON data store used for a combobox selection which is working
I have a datagridview and a combobox which get populated randomly with data. However,
I have this ArrayCollection filled with a xml data coming from and HttpService request.
I have a ComboBox with the ItemsSource data bound. This ComboBox also listens to
So, lets say I have a ComboBox with a custom data template. One of
I have a combobox which binds data from the database. It gets the data
Suppose I have one combo box and I am switching its data provider from
I have a combobox in a view that is tied to a data store

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.