1. #1
    Sencha User
    Join Date
    Oct 2010
    Posts
    159
    Vote Rating
    0
    mdavis6890 is on a distinguished road

      0  

    Default Answered: ComboBox Store filters twice on first click

    Answered: ComboBox Store filters twice on first click


    **Moved from bugs forum***

    I've got an 'expand' listener on my combobox that I want to use to filter the store. Unfortunately, the store seems to filter or load twice on the first click, once the way it's supposed to and a second time with no filter. Subsequent clicks filter properly.

    PHP Code:

    Ext
    .define('Test', {
        
    extend 'Ext.data.Model',
        
    fields : [{name 'fname'type 'string'}]
    });
    Ext.create('Ext.form.field.ComboBox', {
        
    renderTo Ext.getBody(),
        
    store Ext.create('Ext.data.Store', {
            
    model 'Test',
            
    data : [{fname 'Michael'}, {fname 'Jeffrey'}],
            
    listeners : {
                
    'datachanged' : function (store) {
                    
    console.log(store.getCount());
                }
            }
        }),
        
    valueField 'fname',
        
    displayField 'fname',
        
    queryMode 'local',
        
    listeners : {
            
    expand : function (picker) {
                var 
    store picker.getStore();
                
    store.filter('fname''Michael');
            }
        }
    }); 
    So what can I do to make this work right? I've spent many hours to get to this point, and any suggestions would be greatly appreciated.

  2. See:

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

    I think you need to add lastQuery: '' to your config. Whilst this is documented I must say it's always felt like a bug to me.

  3. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,575
    Answers
    540
    Vote Rating
    311
    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


    See:

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

    I think you need to add lastQuery: '' to your config. Whilst this is documented I must say it's always felt like a bug to me.

  4. #3
    Sencha User
    Join Date
    Oct 2010
    Posts
    159
    Vote Rating
    0
    mdavis6890 is on a distinguished road

      0  

    Default


    I'm almost literally in tears right now. I have spent dozens of hours on this in pursuit of a nice, clean and very generalized linked-combo plugin. I think I finally have it.

    Must run now, but I'll post my plugin later once I know it's working properly.

    Thanks!!

  5. #4
    Sencha User
    Join Date
    Oct 2010
    Posts
    159
    Vote Rating
    0
    mdavis6890 is on a distinguished road

      0  

    Default


    PHP Code:

    Ext
    .define('IDB.selectbox.LinkedComboPlugin', {
        
    extend'Ext.AbstractPlugin',
        
    alias'plugin.linkedcombo',
        
    /*    Must pass object like    {
            comboId : 'myLinkedCombo',
            thisField : 'thisField',
            thatField : 'thatField'
        }    */
        
    linkedCombo undefined// Configuration object that looks like above
        
    combo undefined// The combo attached to this plugin

        
    getLinkedCombo : function () {
            return 
    Ext.ComponentQuery.query('#' this.linkedCombo.comboId)[0];
        },

        
    getLinkedRecord : function () {
            var 
    lc this.getLinkedCombo(),
                  
    store lc.store,
                  
    linkedRecord store.findRecord(lc.valueFieldlc.getValue(), 0falsetruetrue);
            return 
    linkedRecord;
        },

        
    onComboExpand : function (pickereOpts) {
             var 
    lc this.getLinkedCombo(),
                   
    record this.getLinkedRecord(),
                   
    filterValue,
                   
    filterStore picker.getStore(),
                   
    remoteField this.linkedCombo.thatField,
                   
    filterProperty this.linkedCombo.thisField;

              if (
    record) {
                
    filterValue record.get(remoteField);
                
    filterStore.clearFilter();
                
    filterStore.filter([{
                    
    property filterProperty,
                    
    value filterValue,
                    
    exactMatch true
                
    }]);
              }
        },
        
    init : function (combo) {
            
    this.combo combo;
            
    Ext.apply(combo, {
                
    lastQuery ''
            
    });

            
    // Filter this combo on expand event, based on value of linked combo.
            
    combo.on('expand'this.onComboExpandthis);

            
    // When the linked combo is changed by the user, clean this combo's value.
            
    combo.mon(this.getLinkedCombo(), 'select', function () {
                
    combo.clearValue();
                
    combo.fireEvent('select');
            }, 
    this);
        }
    }); 

Thread Participants: 1

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..." hd porno faketaxi