2
votes

Using ExtJS 4.2.1, how would you code a "combo" box to query on the displayField rather than the valueField when a user begins typing in the combo's input field?

The following is the setup I have for the 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' }
    })
1
Yes I realize that, but is there a way to override which field is matched against?Jubz
If you want to display something different use the template methods to shape your display. I dont understand what is the issue.dbrin
The issue: you have a combo loaded with data already (as in the code above). When you start typing in the combo, it matches records starting with the characters you typed. It seems to me that it matches based on valueField rather than the displayField. Is that not so, and if so, how do you cause it to match anywhere in the displayFields?Jubz
That s is not so as demonstrated by the example in the combobox API docdbrin

1 Answers

0
votes

The solution detailed in this blog post solves my issue. Seems like I needed a way to make the matching non-case-sensitive. And it is true that matching is done on the displayField's raw value.

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