Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-8947 in 4.2.1.744.
  1. #11
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,592
    Vote Rating
    323
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    rawQuery doesn't seem to be used in beforeQuery. I assume that's passed just in case a subclass finds it useful?

    Perhaps the queryPlan object should be created in doQuery and passed to beforeQuery, it might help to keep it future compatible if other parameters come along later?

    Code:
    queryPlan = me.beforeQuery({
        query: queryString,
        forceAll: forceAll,
        rawQuery: rawQuery,
        combo: me,
        cancel: false
    });
    and:

    Code:
    beforeQuery: function(queryPlan) {
        ...
    }
    A beforeQuery method is a good start but I feel there's potentially a lot of benefit in factoring out the bits inside the local/remote bifurcation, that's where most of the patching tends to happen. Coming up with a decent API for that without exposing too many implementation details may be tricky though.

    Nested 'ifs' four levels deep followed by a massive bifurcation... just the indentation waveform is enough to set alarm bells ringing, you don't even have to read the code.

  2. #12
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,502
    Vote Rating
    48
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Good points. I'll split into doLocalQuery and doRemoteQuery.

  3. #13
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,502
    Vote Rating
    48
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    The new doQuery:

    Code:
        doQuery: function(queryString, forceAll, rawQuery) {
            var me = this,
    
                // Decide if, and how we are going to query the store
                queryPlan = me.beforeQuery({
                    query: queryString || '',
                    rawQuery: rawQuery,
                    forceAll: forceAll,
                    combo: me,
                    cancel: false
                });
    
            // Allow veto.
            if (queryPlan === false || queryPlan.cancel) {
                return false;
            }
    
            // Make sure they aren't using the same value as last time
            if (!me.queryCaching || queryPlan.query !== me.lastQuery) {
                me.lastQuery = queryPlan.query;
    
                if (me.queryMode === 'local') {
                    me.doLocalQuery(queryPlan);
    
                } else {
                    me.doRemoteQuery(queryPlan);
                }
            }
    
            return true;
        },
    Each branch (local/remote) has to call afterQuery in its own way because local will be synchronous, and remote could be asynchronous, and will call it in e store load callback.

    Much cleaner!

  4. #14
    Sencha Premium Member dnoizet's Avatar
    Join Date
    Aug 2012
    Posts
    78
    Vote Rating
    0
    dnoizet is an unknown quantity at this point

      0  

    Lightbulb


    Edit: sorry, what I wrote below does not work as expected.

    In order to make anyMatch with typeAhead work, I added the following code in doLocalQuery:


    Code:
    ...
    // Filter the Store according to the updated filter
    me.store.filter();
    
    // Expand after adjusting the filter unless there are no matches
    if (me.store.getCount()) {
         /* added by me */
         me.getPicker().refresh();
         /* end added by me */            
         me.expand();
    } else {
        me.collapse();
    }
    ...
    This has for effect to refresh the picker as I type
    Last edited by dnoizet; 29 Mar 2013 at 8:24 AM. Reason: does not work

  5. #15
    Sencha Premium Member dnoizet's Avatar
    Join Date
    Aug 2012
    Posts
    78
    Vote Rating
    0
    dnoizet is an unknown quantity at this point

      0  

    Default


    I solved it. I changed :

    Code:
            // Create our filter when first needed
            if (!me.queryFilter) {
                // Create the filter that we will use during typing to filter the Store
                me.queryFilter = new Ext.util.Filter({
                    id: me.id + '-query-filter',
                    anyMatch: me.anyMatch,
                    caseSensitive: me.caseSensitive,
                    root: 'data',
                    property: me.displayField
                });
                me.store.addFilter(me.queryFilter, false);
            }
    To :
    Code:
            // Create our filter when first needed
            if (!me.queryFilter || me.anyMatch) {
                // Create the filter that we will use during typing to filter the Store
                me.queryFilter = new Ext.util.Filter({
                    id: me.id + '-query-filter',
                    anyMatch: me.anyMatch,
                    caseSensitive: me.caseSensitive,
                    root: 'data',
                    property: me.displayField
                });
                me.store.addFilter(me.queryFilter, false);
            }
    And now it reacts to anyMatch
    Last edited by dnoizet; 1 Apr 2013 at 11:22 PM. Reason: formatting

  6. #16
    Sencha User IT100's Avatar
    Join Date
    Jun 2008
    Location
    Oostende, Belgium
    Posts
    71
    Vote Rating
    0
    IT100 is on a distinguished road

      0  

    Default


    I'm baffled by the complexity of all of this.

    could you tell me where you got the information that explains this: (queryPlan)


    queryPlan = me.beforeQuery({ query: queryString, forceAll: forceAll, rawQuery: rawQuery, combo: me, cancel: false });thanks.