EXTJS:过滤器存储不会发生组合的第一次单击

发布于 2024-09-16 21:03:09 字数 2986 浏览 1 评论 0原文

我想在从组合中选择值时过滤商店。当我选择第一个值时,它不会过滤它,但在第二次选择任何其他值时,它效果很好 我的商店有 autoLoad=true 这是我的代码

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

御弟哥哥 2024-09-23 21:03:09

如果选择事件被触发两次,则使用缓冲区配置,它将缓冲事件以仅触发一次。另外,上面的链接是 http://www.sencha.com/forum/ 的重复链接showthread.php?134147 已在 4.0.2 中修复(至少我们的错误跟踪器是这么说的)。

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文