4

i want to filter a store on selecting value from combo. when i select first value it does not filter it but on selecting anyother value 2nd time it works well my store has autoLoad=true here is my code

xtype: 'combo'
,fieldLabel: 'Online Type'
,name:'OnlineType'
,id:'cmbOnlineType'
,store: common.getStore(accounts20.dataForms.onlinePayments._storeOnlineType, accounts20.dataForms.onlinePayments)
,displayField:'OnlineType'
,valueField:'OnlineType'
,mode:'local' // important property when using store
,typeAhead: true
,triggerAction: 'all'
,selectOnFocus:true
,allowBlank:false
,forceSelection:true
,editable:true
,tabIndex:4
,width : 188
,listeners:{
    select:function(){
        if(Ext.getCmp('onlinePay-hdnMode').value!="E")
        {
            Ext.getCmp('onlinePay-cmbChequeNo').clearValue();
            Ext.getCmp('onlinePay-cmbChequeNo').getStore().removeAll();
            Ext.getCmp('onlinePay-cmbCrAccount').clearValue();
        }
        var store = Ext.getCmp('onlinePay-cmbCrAccount').getStore();
        if(this.getValue()=="Cheque" || this.getValue()=="Internet/Mobile")
        {   
            Ext.getCmp('onlinePay-chkIncCharges').setValue(false);
            if(this.getValue()=="Internet/Mobile")
            {
                Ext.getCmp('onlinePay-cmbChequeNo').disable();
                Ext.getCmp('onlinePay-chkIncCharges').disable();
            }else{
                Ext.getCmp('onlinePay-cmbChequeNo').enable();
                Ext.getCmp('onlinePay-chkIncCharges').enable();
            }
            //Filter store on bank accounts
            store.filter([
                {
                    property     : 'AccountTypeId',
                    value        : 'B',//Bank Accounts
                    anyMatch     : true, //optional, defaults to true
                    caseSensitive: false  //optional, defaults to true
                } ,
                //filter functions can also be passed
                {
                    fn   : function(record) {
                        return record.get('AccountTypeId') == 'B';
                    },
                    scope: this
                }
            ]);
        }else if(this.getValue()=="Cash"){
            Ext.getCmp('onlinePay-chkIncCharges').setValue(true);
            Ext.getCmp('onlinePay-chkIncCharges').disable();
            Ext.getCmp('onlinePay-cmbChequeNo').disable();
            //Filter store on cash accounts
            store.filter([
                {
                    property     : 'AccountTypeId',
                    value        : 'C',//Cash Accounts
                    anyMatch     : true, //optional, defaults to true
                    caseSensitive: false  //optional, defaults to true
                } ,
                //filter functions can also be passed
                {
                    fn   : function(record) {
                        return record.get('AccountTypeId') == 'C';
                    },
                    scope: this
                }
            ]);
        }
    }//end of select function
}//end of listener
Rene Saarsoo
  • 13,580
  • 8
  • 57
  • 85
Saima
  • 41
  • 1
  • 6

2 Answers2

7

Define lastQuery: ''

http://dev.sencha.com/deploy/dev/docs/source/Combo.html#prop-Ext.form.ComboBox-lastQuery

Mark
  • 71
  • 2
  • 1
    I spend about 2 hours trying to understand why my filter doesn't work, you like saved me, thanks! – igor May 15 '13 at 11:37
0

If the select event is fired twice use the buffer config, it will buffer the event to only fire one. Also, the link above is a duplicate of http://www.sencha.com/forum/showthread.php?134147 which was fixed in 4.0.2 (at least that's what our bug tracker says).

Mitchell Simoens
  • 2,516
  • 2
  • 20
  • 29