PDA

View Full Version : Simple combobox item with data from mysql doesn't work



maxritti
2 Jun 2012, 10:47 AM
Hello all,

i hope that anyone can help me.
I'm trying to fill values in a combobox based on a php script which gets data from a mysql database.

My php script returns following three example values.

[{"Categorie":"Categorie 1"},{"Categorie":"Categorie 2"},{"Categorie":"Categorie 3"}]


var CatStore = new Ext.data.JsonStore({
url : 'scripts/get_categories.php',
root : 'Categorie',
fields : ['Categorie']
});

...
items: [{
xtype : 'combo',
loadingText : 'Loading...',
store : CatStore,
displayField : 'Categorie',
valueField : 'Categorie',
typeAhead : 'true',
mode:'remote',
forceSelection:true,
emptyText:'Select categorie...'
}
...


But now if i click on the combobox firebug returns following error:

"a is undefined".

I don't know where i can find the error.

chramer
2 Jun 2012, 11:29 AM
"url" is a property for the proxy..
"root" is a property for the reader (you don't need this cause there is no root in your response)

check these examples : http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.JsonStore

maxritti
2 Jun 2012, 11:06 PM
Thank you very much.
That works fine.