Results 1 to 4 of 4

Thread: [4.1] ComboBox getValue returns displayField instead of valueField

    You found a bug! We've classified it as EXTJS-8065 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1

    Default [4.1] ComboBox getValue returns displayField instead of valueField

    Method getValue returns displayField instead of valueField when value containes a "\n".
    I've used a modified combobox from your examples.
    Just replace the following code with the first combobox located in "examples/form/combo.html":

    Code:
        // Simple ComboBox using the data store
        var simpleCombo = Ext.create('Ext.form.field.ComboBox', {
            fieldLabel: 'Select a single state',
            renderTo: 'simpleCombo',
            displayField: 'name',
            width: 320,
            displayField: 'description',
            valueField: 'value',
            labelWidth: 130,
            store: Ext.create('Ext.data.Store', {
                fields: ['value', 'description'],
                data: [
                    {value: '123', description: 'Hello test'},
                    {value: '1234', description: 'Hello\ntest2'}
                ],
                proxy: {
                    type: 'memory',
                    reader: {
                        type: 'json'
                    }
                }
            }),
            listeners: {
                select: function() {
                    console.log('value', this.getValue());
                }
            },
            queryMode: 'local',
            typeAhead: true
        });
    Tested with ExtJS 4.1.0 and 4.1.1a

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379

    Default

    Thanks for the report! I have opened a bug in our bug tracker.

  3. #3
    Sencha Premium Member
    Join Date
    Jul 2007
    Posts
    6

    Default

    I'm also facing this issue still using 4.1.3.

    Has the bu been solved or a workaround found by anyone?

    thanks

  4. #4
    Sencha Premium Member
    Join Date
    Jul 2007
    Posts
    6

    Default

    I managed to solve this with the following work around.

    Set your displayField and valueField to always be the same, so even if the displayField is returned you will have the correct value.

    Then override the displayTpl to show what you actually want. eg:

    Code:
    component.displayTpl = Ext.create('Ext.XTemplate',
                           '<tpl for=".">',
                           '{displayField}',
                           '</tpl>'
                          );

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •