1. #1
    Sencha User
    Join Date
    Sep 2010
    Location
    Riga, Latvia
    Posts
    4
    Vote Rating
    0
    bmg1 is on a distinguished road

      0  

    Exclamation Unanswered: ComboBox not update after ComboBox.store.filterBy

    Unanswered: ComboBox not update after ComboBox.store.filterBy


    Hi!

    if i'm not select with mouse in ComboBox and filtring ComboBox.store.filterBy:
    ComboBox not update - all values is present, that in ComboBox.store is other.

    and i'm select with mouse and filtring ComboBox.store.filterBy:
    now is ComboBox is updatet and not present that is filtred.

    I need filtring before user is select with mouse.
    Please help.



    Code:
        
    var isDealer = false;
    
    var marketStore = Ext.create('Ext.data.Store', {fields: ['id', 'text', 'parent'], data: [{"id":3,"text":"LV - Latvia","parent":"426"},{"id":2,"text":"EE - Estonia","parent":"426"},{"id":7,"text":"LT - Lithuania","parent":"426"},{"id":5,"text":"BY - Belarus","parent":"428"},{"id":4,"text":"UA - Ukraine","parent":"428"}]});
    
    marketStore.sort('text', 'ASC'); marketStore.insert(0, {"id":0,"text":"All","parent":0});
    
        var marketSelect = Ext.create('Ext.form.ComboBox', {
            width: 280,
            disabled: ((isDealer?true:false)),
            autoWidth: true,
            triggerAction: 'all',
            monitorResize: true,
            fieldLabel: 'Market',
            labelAlign: 'right',
            labelWidth: 70,
            store: marketStore,
            queryMode: 'local',
            displayField: 'text',
            valueField: 'id',
            name: 'market_id',
            id: 'market_id',
            autoScroll: true
        });
    
        marketSelect.setValue(marketStore.getAt((isDealer?1:0)).get('id'));
        formItems.push(marketSelect);
    
        var cmpEl = Ext.getCmp('market_id');
            cmpEl.clearValue();
            cmpEl.store.clearFilter();
            cmpEl.store.filterBy(function(record, id){
                    var idGet = record.get('parent');
                    return idGet == 426;
            });
             var selectID = cmpEl.store.getAt('0').get('id');
            cmpEl.setValue(selectID);

  2. #2
    Sencha User tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,669
    Answers
    130
    Vote Rating
    110
    tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all

      0  

    Default


    you have the config
    Code:
    triggerAction: 'all',
    so, whenever a user clicks on the trigger, the filter gets removed.
    Best regards
    Tobias Uhlig
    __________

    S-CIRCLES Social Network Engine

  3. #3
    Sencha User
    Join Date
    Sep 2010
    Location
    Riga, Latvia
    Posts
    4
    Vote Rating
    0
    bmg1 is on a distinguished road

      0  

    Default


    Thanks Your for help.

    But, with and without:
    Code:
    triggerAction: 'all',
    not work.

    I'm use:
    Code:
    Ext.getCmp('market_id').onTriggerClick();Ext.getCmp('market_id').collapse();
    before filterBy. But that is no good solution.
    ==============================================
    Qui quaerit, reperit.

  4. #4
    Sencha User
    Join Date
    Sep 2010
    Location
    Germany
    Posts
    53
    Answers
    2
    Vote Rating
    2
    HTK is on a distinguished road

      0  

    Default


    You could use filters option in store config. Then filter would be applied directly if data gets loaded.

  5. #5

  6. #6
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,590
    Answers
    541
    Vote Rating
    322
    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


    triggerAction: 'all' will cause clicking the trigger to always show the full list of values. Removing it won't help, you need to explicitly set it to triggerAction: 'query'.

    As mentioned by SilentBob, if you apply filtering to the combobox's store before you first show the drop-down then you'll need to set lastQuery.

    http://docs.sencha.com/ext-js/4-0/#!...erty-lastQuery

  7. #7
    Sencha User
    Join Date
    Sep 2010
    Location
    Germany
    Posts
    53
    Answers
    2
    Vote Rating
    2
    HTK is on a distinguished road

      0  

    Default


    Setting the lastQuery property to empty string, was the best solution for me.
    Code:
    lastQuery: ''

  8. #8
    Sencha User
    Join Date
    Nov 2010
    Location
    Canada
    Posts
    8
    Vote Rating
    0
    smatric is on a distinguished road

      0  

    Default


    I thought I would share my solution to a very similar problem I had. In my case:
    1. user types a prefix of a value in a combobox (which triggers filtering in a store linked with the combobox)
    2. user, through interaction with UI, changes data in the store (via filters)
    After the two steps, the combobox would have both old and new values (as if filters were erased).


    Here is what I did.


    a) UI component that changes the store:
    Code:
    change: function(combo, newSubsetKey) {
        //...
        store.removeAll();
        store.add(subsetOfData(data, newSubsetKey));
    }

    b) in the combobox:
    Code:
    {
    xtype: 'combobox',
    store: 'Store',
    //...
    queryMode: 'local',
    listeners: {
        beforequery: function(queryEvent) {
            if(queryEvent.query == '') {
                queryEvent.combo.lastQuery = '';
                //...
                store.clearFilter(true);
                store.filter(filterField, filterValue);
            }
        }
    },
    //...
    }