简体   繁体   English

扩展单击时Extjs空组合框值

[英]Extjs empty combo box value on expand click

i have created lazy loading combo box, which queries data by entered value. 我创建了延迟加载组合框,它按输入的值查询数据。 But i have issue when value is loaded from database and i click expand list button, it sends request with empty mask instead of taking value of combobox, it seems, that empty value is taken for some reason. 但是当我从数据库加载值时我有问题,我点击展开列表按钮,它发送带空掩码的请求而不是取组合框的值,看来,由于某种原因,该值为空值。

Here is my combo box : 这是我的组合框:

editor : {
            xtype : 'lazycombo',
            minChars : 1,
            pageSize : 20,
            id : 'tax-code-combo',
            store : 'TaxCodesStore',
            triggerAction : 'all'
        }

and here is request params : 这是请求参数:

limit   20
mask    
organizationId  108
start   0

mask is empty instead of before set value. mask是空的而不是在设置值之前。

Thanks for help 感谢帮助

my store : 我的商店:

TaxCodesStore = Ext.extend(Ext.data.JsonStore, {
constructor : function(cfg) {
    cfg = cfg || {};
    TaxCodesStore.superclass.constructor.call(this, Ext.apply({
        storeId : 'TaxCodesStore',
        api : {
            read : 'taxCode/getPagedList'
        },
        root : 'data',
        baseParams : {
            organizationId : 0
        },
        idProperty : 'taxCode',
        fields : [ {
            mapping : 'taxCode',
            name : 'value'
        }, {
            mapping : 'taxCode',
            name : 'label'
        }, {
            name : 'orgId',
            type : 'int'
        }, {
            name : 'percentageRate',
            type : 'int'
        } ]
    }, cfg));
}
});

new TaxCodesStore();

Update 更新

What i have found after investigation, that combo box method getValue() returns the value, but for some reason in is not set as store param mask on request. 我在调查后发现,组合框方法getValue()返回值,但由于某种原因未在请求时设置为存储参数掩码。

The "store" property mast be a reference on a such Ext.data.Store object: “store”属性mast是对此类Ext.data.Store对象的引用:

store: Ext.create('TaxCodesStore', { ... });

Also need to configure "displayField" and "valueField" properties. 还需要配置“displayField”和“valueField”属性。

UPD : UPD

    {
        xtype : 'lazycombo',
        minChars : 1,
        pageSize : 20,
        id : 'tax-code-combo',
        store : new TaxCodesStore(), // <---
        triggerAction : 'all',
        displayField: 'origId', // <---
        valueField: 'value' // <---
    }

Maybe this will help you 也许会对你有所帮助

HTML HTML

<div id="cmb"></div>

Javascript 使用Javascript

Ext.onReady(function(){
    var store = Ext.create('Ext.data.Store', {
        fields: ['id', 'attr'],
        proxy: {
            type: 'ajax',
            api: {
                read: '/someurl'
            },
            reader: {
                type: 'json',
                root: 'data',
                successProperty: 'success',
                totalProperty: 'total'
            }
        }
    });
    var cmb   = Ext.create('Ext.form.field.ComboBox', {
        triggerAction: 'all',
        store: store,
        displayField: 'attr',
        valueField: 'id',
        queryMode: 'remote',
        listeners: {
            beforequery: function(){
                this.getStore().getProxy().extraParams.mask = this.getValue();
            }
        }
    });


    cmb.render('cmb');

})

After debugging the source, i have found there the problem was. 调试源后,我发现问题所在。

It was because of triggerAction : 'all', i removed it, and now my combo works perfect 这是因为triggerAction : 'all',我删除它,现在我的组合工作完美

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM