Sergey Metlov
Sergey Metlov

Reputation: 26291

Combobox + XTemplate trouble

Folloving example shows normal combobox until I use XTemplate. After applying XTemplate combobox items become unclickable (no highlight on hover and no choosing by click).

    Ext.onReady(function () {
        var states = Ext.create('Ext.data.Store', {
            fields: ['abbr', 'name'],
            data: [
                { "abbr": "AL", "name": "Alabama" },
                { "abbr": "AK", "name": "Alaska" },
                { "abbr": "AZ", "name": "Arizona" }
            ]
        });

        Ext.create('Ext.form.ComboBox', {
            fieldLabel: 'Choose State',
            store: states,
            queryMode: 'local',
            displayField: 'name',
            valueField: 'abbr',
            renderTo: 'divId',
            tpl: new Ext.XTemplate(
                '<tpl for="."><div class="x-combo-list-item">{name}</div></tpl>')
        });
    }

Upvotes: 2

Views: 5180

Answers (2)

Thevs
Thevs

Reputation: 3253

There is no need for new Ext.Xtemplate in tpl value. Just define a template string within it.

Upvotes: 2

dmackerman
dmackerman

Reputation: 2966

The default XTemplate for ComboBox is:

'<tpl for="."><div class="x-combo-list-item">{' + this.displayField + '}</div></tpl>'

You already have set the displayField to name, so why would you need a custom template?

Upvotes: 4

Related Questions