MARKAND Bhatt
MARKAND Bhatt

Reputation: 2630

Sencha ComboBox- something wrong with store binding

This is my Combobox

 xtype: 'combo',
            emptyText: 'No Data Found',
            labelStyle: 'margin-bottom:5px;',
            fieldLabel: 'Categories',
            labelAlign: 'top',
            id: 'cmbCategories',
            store: ['Age','Sex','Occupation'],
            editable: false,
            queryMode: 'local',
            matchFieldWidth: false,
            listConfig: {
                width: 250
            }

The problem is I always get empty text i.e 'No data found'. I dont know why my data does not bind.

Upvotes: 0

Views: 371

Answers (3)

xGeo
xGeo

Reputation: 2139

your store is wrong : store: ['Age','Sex','Occupation'],

this should be :

store: Ext.create('Ext.data.Store', {
          fields: ['name', 'value'],
           data : [
             {"name":"Age", "value": 0 },
             {"name":"Sex", "value": 1 },
             {"name":"Location", "value": 2 }
           ]
       }),
displayField: 'name',
valueField: 'value',
editable: false,
....

Upvotes: 0

Saki
Saki

Reputation: 5856

What do you expect? The combo as you configured it works fine. If you want a value in the textfield part of it then you must select an item from the dropdown list. If you want the combo to have a value initially, just add it to the config, e.g. value:'Age'

Upvotes: 1

Sanmao
Sanmao

Reputation: 11

var states = Ext.create('Ext.data.Store', {

    fields: ['abbr', 'name'],
    data : [
        {"abbr":"AL", "name":"Alabama"},
        {"abbr":"AK", "name":"Alaska"},
        {"abbr":"AZ", "name":"Arizona"}
    ]

});

store: states, displayField: 'name', valueField: 'abbr',

Upvotes: 1

Related Questions