【问题标题】:Extjs empty combo box value on expand clickExtjs 在展开单击时为空组合框值
【发布时间】:2013-08-29 18:46:38
【问题描述】:

我创建了延迟加载组合框,它通过输入的值查询数据。但是当我从数据库加载值并单击展开列表按钮时出现问题,它发送带有空掩码的请求而不是获取组合框的值,似乎由于某种原因而采用了空值。

这是我的组合框:

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

这里是请求参数:

limit   20
mask    
organizationId  108
start   0

掩码为空,而不是设置值之前。

感谢您的帮助

我的商店:

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();

更新

我在调查后发现,组合框方法getValue() 返回值,但由于某种原因 in 未根据请求设置为存储参数掩码。

【问题讨论】:

    标签: javascript extjs combobox


    【解决方案1】:

    “store”属性可以作为 Ext.data.Store 对象的引用:

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

    还需要配置“displayField”和“valueField”属性。

    UPD

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

    【讨论】:

    • 我已经添加了我的商店实现
    • 感谢您的建议,但它对我不起作用,我得到同样的错误
    【解决方案2】:

    也许this会帮助你

    HTML

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

    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');
    
    })
    

    【讨论】:

      【解决方案3】:

      调试源码后发现问题出在了那里。

      是因为triggerAction : 'all',我删除了它,现在我的组合完美了

      【讨论】:

        猜你喜欢
        • 2021-06-08
        • 2021-12-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-02-09
        • 1970-01-01
        • 2011-04-29
        相关资源
        最近更新 更多