首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

急Extjs4.1 的combo检索数据有关问题 ~

2013-01-21 
急急急!!!Extjs4.1 的combo检索数据问题 ~~~~~~~~~~~~~先给大家上图这是一个国家代码下拉列表我输入内容可

急急急!!!Extjs4.1 的combo检索数据问题 ~~~~~~~~~~~~~
先给大家上图
这是一个国家代码下拉列表急Extjs4.1 的combo检索数据有关问题 ~

我输入内容可以自动检索符合的数据,急Extjs4.1 的combo检索数据有关问题 ~

然后我选择检索到的数据后   在同一个页面的另一个国家代码就不能选择其他的了,只能选择第一个下拉框选择的数据
急Extjs4.1 的combo检索数据有关问题 ~


请教大神们 这是什么原因啊?

下面是combo的代码


//通用 国家(地区)代码
Ext.define("Ext.common.crehqcode", {
    alias: 'widget.mycombo',
    extend: 'Ext.form.field.ComboBox',
    store: new Ext.store.Common.FogurecodeStore(),
    labelAlign: 'right',
    selectOnFocus: true, // 字段获取焦点时自动选择字段既有文本
    triggerAction: 'all', // 触发器被激活时执行的动作,使用'all'来运行由allQuery属性指定的查询
    loadingText: '加载中……',
    queryMode: 'local',
    //typeAhead: true,
    value: 'CHN',
    displayField: 'fogurecodeName',
    valueField: 'fogurecodeId',

    initComponent: function () {
        var me = this;

        me.id = me._id;
        me.name = me._name;

        if (!Ext.isEmpty(me._hidden)) {
            me.hidden = me._hidden;
        } else {
            me.hidden = false;
        }
        if (me._allowBlank) {
            me.fieldLabel = me._label;
            me.allowBlank = me._allowBlank;
        } else {
            me.allowBlank = false;
            me.fieldLabel = '<font color="red">*</font>' + me._label;
            me.blankText = me._label + '不能为空!';
        }

        me.callParent(arguments);
    }
});
extjs javascript
[解决办法]
你引用了同一个store对象的问题,对一个检索后其他引用同一个store对象的combo也会显示过滤后的数据

你可以给combox增加focus事件clear掉过滤条件
//通用 国家(地区)代码
Ext.define("Ext.common.crehqcode", {
    alias: 'widget.mycombo',
    extend: 'Ext.form.field.ComboBox',
    store: new Ext.store.Common.FogurecodeStore(),
    labelAlign: 'right',
    selectOnFocus: true, // 字段获取焦点时自动选择字段既有文本
    triggerAction: 'all', // 触发器被激活时执行的动作,使用'all'来运行由allQuery属性指定的查询


    loadingText: '加载中……',
    queryMode: 'local',
    //typeAhead: true,
    value: 'CHN',
    displayField: 'fogurecodeName',
    valueField: 'fogurecodeId', 
////////////////////////////////////////获取交掉后清空过滤条件
    listeners:{focus:function(cb){cb.getStore().clearFilter()}},
////////////////////////////////////////
    initComponent: function () {
        var me = this;
 
        me.id = me._id;
        me.name = me._name;
 
        if (!Ext.isEmpty(me._hidden)) {
            me.hidden = me._hidden;
        } else {
            me.hidden = false;
        }
        if (me._allowBlank) {
            me.fieldLabel = me._label;
            me.allowBlank = me._allowBlank;
        } else {
            me.allowBlank = false;
            me.fieldLabel = '<font color="red">*</font>' + me._label;
            me.blankText = me._label + '不能为空!';
        }
 
        me.callParent(arguments);
    }
});

热点排行