i want to load my Combobox in a Panel from Store.
var colors = new Object();
Ext.onReady(function(){
colors = Ext.create('Ext.data.Store', {
fields: ['id', 'name'],
autoLoad: true,
proxy: {
type: 'ajax',
url: 'app/view/main/loadFromDatabase.php',
reader: {
type: 'json',
rootProperty: 'name'
}
},
});
The colors i want load a little bit later in my Panel like this:
{ xtype: 'combo',
fieldLabel: 'Farbe',
name: 'farbe',
store: colors ,
queryMode: 'local',
displayField: 'name',
valueField: 'id' }
The response of my ajax request of loadFromDatabase.php is:
[ { "id": "1", "name": "Red" }, { "id": "2", "name": "Blue" }, { "id": "3", "name": "Green"}]
this seems like a valid json.
But when i click on the combobox the box is empty. Whats wrong?
name
however, your response hasn't a root property so that should probably berootProperty: ''
or if you create a root property likeitems
in @sreek521's example. TherootProperty : 'items'
– weeksdev