1. #1
    Ext GWT Premium Member
    Join Date
    Dec 2008
    Location
    Milwaukee
    Posts
    33
    Vote Rating
    3
    meyersd is on a distinguished road

      0  

    Default ComboBox Type Ahead, detect matching characters other than from the beginning

    ComboBox Type Ahead, detect matching characters other than from the beginning


    My ListStore contains full names (i.e. John Doe). I want type ahead to match not only on first name, but on last name as well. This is the behavior of GWT SuggestBox.

    Is there a setter that I can call to enable this behavior? My code is:

    Code:
    ComboBox<ModelData> combo = new ComboBox<ModelData>();
    combo.setDisplayField("display");
    combo.setId("id");
    combo.setStore(listStore);
    combo.setTypeAhead(true);
    combo.setTriggerAction(ComboBox.TriggerAction.ALL);

  2. #2
    Ext GWT Premium Member mariusz.pala's Avatar
    Join Date
    Jun 2008
    Location
    Poland
    Posts
    298
    Vote Rating
    2
    mariusz.pala is on a distinguished road

      0  

    Default


    You need to customize your Store. There is a simple change required in applyFilters method (change beginsWith to contains):

    Code:
    public class CustomListStore<M extends ModelData> extends ListStore<M> {
    
        /**
         * Applies the current filters to the store.
         * 
         * @param property
         *            the optional active property
         */
        @Override
        public void applyFilters(String property) {
            filterProperty = property;
            if (!filtersEnabled) {
                snapshot = all;
            }
    
            filtersEnabled = true;
            filtered = new ArrayList<M>();
            for (M items : snapshot) {
                if ((filterBeginsWith != null) && (property != null)) {
                    Object o = items.get(property);
                    if (o != null) {
                        if (!o.toString().toLowerCase().contains(filterBeginsWith.toLowerCase())) {
                            continue;
                        }
                    }
                }
                if (!isFiltered(items, property)) {
                    filtered.add(items);
                }
            }
            all = filtered;
    
            if (storeSorter != null) {
                applySort(false);
            }
    
            fireEvent(Filter, createStoreEvent());
        }
    }

  3. #3
    Ext GWT Premium Member
    Join Date
    Dec 2008
    Location
    Milwaukee
    Posts
    33
    Vote Rating
    3
    meyersd is on a distinguished road

      0  

    Default


    Thanks for the tip. However, this does not work as I would expect. For example if I have some names in my list "Dave Lastname", "George Anothername", "Pete Thirdname". If I type "a" and pause for a second "Dave Lastname" would get put into the combo box in a highlighted mode. If I start typing again the "a" that I had typed would disappear to be replaced by a D. I assume that I need to make an adjustment to my combo box to compensate for this. Any ideas?

  4. #4
    Ext GWT Premium Member
    Join Date
    Dec 2008
    Location
    Milwaukee
    Posts
    33
    Vote Rating
    3
    meyersd is on a distinguished road

      0  

    Default


    The solution for this is:
    Code:
    combo.setTypeAhead(false);
    Even without type ahead the list is filtered as I desire. I can't see the point of ever using setTypeAhead(true);

  5. #5
    Ext GWT Premium Member
    Join Date
    Mar 2008
    Posts
    97
    Vote Rating
    0
    Jeff Miner is on a distinguished road

      0  

    Default Would be nice to incorporate this as a feature

    Would be nice to incorporate this as a feature


    It would be better if this code were maintained by sencha or at least have the code be more OO - overriding applyFilters in this way means copying lots of implementation details (snapshot, filtersenabled, etc.) that could change and could break my code.

    It would be nice to be able to override a simpler boolean typeAheadAccept() method or something like that

    Copying and modifying the source code is always a dodgy operation and it would be nice if we could avoid it

  6. #6
    Ext GWT Premium Member
    Join Date
    Mar 2008
    Posts
    97
    Vote Rating
    0
    Jeff Miner is on a distinguished road

      0  

    Exclamation Any movement on this?

    Any movement on this?


    We're at the point of needing this as a regular feature and I hate over-riding and copying source-code implementation into my over-ride.

    What's the chance that this will become a standard feature?

  7. #7
    Sencha User
    Join Date
    Apr 2013
    Posts
    29
    Vote Rating
    0
    kozla13 is on a distinguished road

      0  

    Default


    The above code is not working for gxt 3.1.1
    Dos someone have a solution for new versions of GXT ?

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..."