Reputation: 2558
This is my JSON data returned from the server. I am not seeing my combo getting loaded. What is wrong here?
{"suffixList":["-1","-2","-3"]}
Model:
Ext.define('ExtMVC.model.Suffix', {
extend: 'Ext.data.Model',
fields: [
{name: 'suffix'}
]
});
Store:
Ext.define('ExtMVC.store.Suffixes', {
extend: 'Ext.data.Store',
model: 'ExtMVC.model.Suffix',
autoLoad : false,
proxy: {
type: 'ajax',
url: 'http://'+window.location.host+'/populateCombo',
reader: {
type: 'json',
root: 'suffixList'
}
}
});
View:
{
xtype:'combo',
id: 'suffix',
name: 'suffix',
store : 'Suffixes',
displayField: 'suffix',
valueField: 'suffix'
}
Upvotes: 3
Views: 4668
Reputation: 995
You can use an ArrayStore
new Ext.data.ArrayStore({
fields: ['suffix'],
data: {suffixList: ['-1', '-2', '-3']},
proxy: {
type:'memory', //'ajax'
reader: {
type: 'array',
root: 'suffixList'
}
}
})
Upvotes: 1
Reputation: 4405
The data is not formatted correctly. Each record should be an object, with properties for the store's fields. In your case, the data should look like this:
{"suffixList":[{"suffix": "-1"},{"suffix": "-2"},{"suffix": "-3"}]}
Upvotes: 0