I am getting a json array string as response from a page. I want to bind it with a combobox.
This is the success block which gives me the json array string:
The json array string looks like this:

Please let me know hoe to bind this with the combobox drop down.
Regards,
EDIT:
This is the latest code I tried:
Ext.define('Country',{
extend: 'Ext.data.Model',
fields: [
{ name: 'id', type: 'string' },
{ name: 'name', type: 'string' }
]
});
Ext.define('CountryCombo', {
extend: 'Ext.form.field.ComboBox',
alias: 'widget.countrycombo',
allowBlank: false,
queryMode: 'local',
valueField: 'id',
displayField: 'name',
store: {
model: 'Country',
data: [
{ id: 'China', name: 'China'},
{ id: 'Japan', name: 'Japan'},
{ id: 'Malaysia', name: 'Malaysia'}
]
},
listeners: {
"select": function(obj){
Ext.Ajax.request({
url: '/CellEditing/FormServlet',
method: 'POST',
params: {
data: obj.getValue()
},
success: function(obj){
alert('success');
alert(obj.responseText);
console.log(StateCombo.storeStates); //This is undefined hence getting error
StateCombo.storeStates.loadData(obj.responseText);
},
failure: function(obj){
alert('failure');
}
});
}
}
});
var storeStates = Ext.create('Ext.data.Store', {
autoLoad: false,
fields: ['State']
});
Ext.define('State',{
extend: 'Ext.data.Model',
fields: [
{ name: 'id', type: 'int' },
{ name: 'name', type: 'string' }
]
});
Ext.define('StateCombo', {
extend: 'Ext.form.field.ComboBox',
alias: 'widget.statecombo',
queryMode: 'local',
valueField: 'State',
displayField: 'State',
store: storeStates
});
This is the latest I tried but still when I select something from 1st combobox, the second combobox is not getting populated. any Help on this please?
Technically this code will work:
http://jsfiddle.net/sdt6585/wPzPD/29/
The major changes are these:
While that technically works, it’s not the most elegant solution. You would be working with much more maintainable code to follow this process.