ExtJS4,将组合框和其他字段添加到面板 - 组合框列表问题

时间:2013-02-18 17:42:28

标签: forms combobox extjs4 row add

首先感谢大家对这些论坛的贡献/帮助。我在网上搜索了好几天,我找不到解决方法/弄清楚什么是错的。 我有一个表单面板,它最初有一个字段(组合框,文本字段,按钮等)的单行(容器使用hbox布局),用户可以使用它来构建布尔语句。此容器还具有“AND”,“OR”和“DEL”按钮,可用于附加另一行(布尔语句)或将当前行删除到表单面板。我有组合框值的本地商店,这项工作一切正常/好......等等。 我的问题是在用户输入任何组合框中的值并且当他们添加新行时,新行的组合框列表仅限于在前一行中选择的内容 - 并且仅限于该值。 我可以看到新行的组合框的存储通过firebug具有所有正确的值,但是这些不能通过GUI访问。我认为这是一个浏览器问题,但不能在Ffox和IE中撼动它。如果他们只通过鼠标选择,这绝不是问题。我已经尝试拆除组合框配置等,使用字段集而不是容器在线搜索。有什么想法/想法吗?

Ext.define('SearchTool.view.main.component.QueryBuilderRow', {
extend: 'Ext.container.Container',
alias: 'widget.builderRow',
requires: ['SearchTool.config.Config'],
layout: 'hbox',
items: [{
    xtype: 'combo',
    cls: 'cboxFields',
    store: new Ext.data.SimpleStore({
        fields: ['fieldname', 'fieldvalue'],
        data: [
            ['field1', 'FIELD1'],
            ['field2', 'FIELD2'],
            ['field3', 'FIELD3'],
            ['field4', 'FIELD4']
        ]
    }),
    editable: true,
    selectOnFocus: false,
    forceSelection: true,
    displayField: 'fieldname',
    valueField: 'fieldvalue',
    emptyText: '(Select Field)',
    typeAhead: true,
    value: '',
    triggerAction: 'query',
    queryMode: 'local',
    width: '15%'
    }, {
    xtype: 'combo',
    cls: 'cboxOpers',
    store: operStore,
    displayField: 'opername',
    valueField: 'opervalue',
    emptyText: '(Select Oper)',
    forceSelection: true,
    typeAhead: true,
    triggerAction: 'query',
    shrinkWrap: 1,
    selectOnFocus: false,
    queryMode: 'local',
    width: '15%',
    enableKeyEvents: true
    }, {
    xtype: 'textfield',
    // itemId: 'val1',
    width: '18%',
    emptyText: '(Enter value...)',
    regex: SearchTool.config.Config.qryBuilderTextFieldRegex,
    regexText: SearchTool.config.Config.qryBuilderErrText,
    enableKeyEvents: true
    }, {
    xtype: 'combo',
    cls: 'cboxAndOr',
    store: andorStore,
    minChars: 1,
    disabled: true,
    displayField: 'opername',
    valueField: 'opervalue',
    typeAhead: true,
    emptyText: '(AND/OR)',
    allowBlank: true,
    enforceMaxLength: true,
    matchFieldWidth: true,
    mode: 'local',
    width: '12%'
    }, {
    xtype: 'textfield',
    width: '17%',
    emptyText: '(Enter value...)'
    }, {
    xtype: 'hidden',
    value: ''
    }, {
    xtype: 'button',
    iconCls: 'icon-btnAdd',
    text: 'AND',
    width: '7%',
    handler: function (t) {
    t.up('panel').add({xtype:'builderRow'}); //add new row
    t.up('panel').items.items[t.up('panel').items.items.length -                     
        2].down('button').next('button').next('button').hide();
    t.prev('hidden').setValue(' AND '); //to be passed in w/ form
    }
    }, {
    xtype: 'button',
    iconCls: 'icon-btnAdd',
    text: 'OR',
    width: '6.5%',
    handler: function (t) {
    t.up('panel').add({xtype:'builderRow'}); //add new row
    t.up('panel').items.items[t.up('panel').items.items.length - 2].down('button').next('button').next('button').hide();
    t.prev('hidden').setValue(' OR ');
    }
    }, {
    xtype: 'button',
    iconCls: 'icon-btnDelete',
    text: 'DEL',
    width: '7%',
    handler: function (t, e, o) {
    var i = t.up('panel').items.items;
    var l = i.length; //length of the array of items
    if (l > 2) i[l - 2].down('button').next('button').next('button').show();
    i[t.up('panel').items.items.length - 2].down('hidden').setValue(''); //prev row hidden reset

    t.up('panel').remove(t.up('container')); //remove this row
    }
}]
});

1 个答案:

答案 0 :(得分:0)

不要为不同的组合框重复使用商店。为每行的每个组合创建新商店。这是因为,当您键入时,您将过滤组合框上的数据。数据包含在商店中,因此您基本上过滤了商店,商店在组合中共享。

因此,一旦您对第1行进行过滤,过滤器对第2行保持活动状态。如果每个组合使用新商店,则不会出现问题。

相关问题