【问题标题】:How to query display field of ComboBox on TypeAhead如何在 TypeAhead 上查询 ComboBox 的显示字段
【发布时间】:2013-11-07 02:05:33
【问题描述】:

使用 ExtJS 4.2.1,当用户开始在组合的输入字段中输入时,如何编写一个“组合”框来查询 displayField 而不是 valueField?

以下是我对 ComboBox 的设置:

    xtype: 'combo',
    itemId: 'usersCbo',
    width: 450,
    forceSelection: true,
    fieldLabel: 'Assign Selected TestRuns To',
    labelAlign: 'right',
    labelWidth: 180,
    queryMode: 'local',
    valueField: 'USERNAME',
    displayField: 'FULLNAMES',
    triggerAction: 'all',
    typeAhead: true,
    allowBlank: false,
    store: Ext.create('Ext.data.Store', {
        storeId: 'testRunUsersStore',
        autoLoad: true,
        pageSize: 1000,
        proxy: {
            type: 'ajax',
            url: 'app/php/stores/Test_Run/testEngineers.php',
            reader: {
                type: 'xml',
                record: 'Record',
                root: 'Records',
                totalProperty : '@totalRecords'
            }
        },
        fields: [
            { name: 'USERNAME',     type: 'string' },
            { name: 'FULLNAMES',    type: 'string' }
        ],
        sortOnLoad: true,
        sorters: { property: 'USERNAME', direction: 'ASC' }
    })

【问题讨论】:

  • 是的,我知道,但是有没有办法覆盖匹配的字段?
  • 如果您想显示不同的内容,请使用模板方法来塑造您的显示。我不明白这是什么问题。
  • 问题:您的组合已经加载了数据(如上面的代码中所示)。当您开始输入组合时,它会匹配以您输入的字符开头的记录。在我看来,它基于 valueField 而不是 displayField 进行匹配。不是这样吗,如果是这样,你如何使它匹配 displayFields 中的任何地方?
  • 这与组合框 API 文档中的示例不同

标签: extjs4


【解决方案1】:

这篇博文中详述的解决方案解决了我的问题。似乎我需要一种方法来使匹配不区分大小写。确实,匹配是在 displayField 的原始值上完成的。

http://atechiediary.blogspot.in/2013/06/first-page-extjs-containslike-search-in.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-30
    • 1970-01-01
    • 2019-10-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多