I am using ExtJS 3.4, and I need to populate a combo box with the following data:
"[{"cod_domini":"1","nom_domini":"Sant Esteve de Palautordera"},{"cod_domini":"2","nom_domini":"Parc Natural del Montseny"},{"cod_domini":"5","nom_domini":"Sant Pere de Vilamajor"},{"cod_domini":"6","nom_domini":"Santa Maria i Mosqueroles"}]"
What happens to the previous XMLHttpRequest, and I got it in a variable, therefore:
my_variable = "[{"cod_domini":"1","nom_domini":"Sant Esteve de Palautordera"},{"cod_domini":"2","nom_domini":"Parc Natural del Montseny"},{"cod_domini":"5","nom_domini":"Sant Pere de Vilamajor"},{"cod_domini":"6","nom_domini":"Santa Maria i Mosqueroles"}]"
So, I have the following ExtJS 3.4 command:
cbxSelDomini = new Ext.form.ComboBox({ hiddenName: 'Domini', name: 'nom_domini', displayField: 'nom_domini', valueField: 'cod_domini', mode: 'local', triggerAction: 'all', listClass: 'comboalign', typeAhead: true, forceSelection: true, selectOnFocus: true, store: mystore });
This combobox is used to retrieve data from the Ext.data.Store file, which I called "mystore":
store: mystore = new Ext.data.Store({ autoload: true, reader: new Ext.data.ArrayReader( { idIndex: 0 // id for each record will be the first element }), data: dataprova, fields: [ {type: 'integer', name: 'cod_domini'}, {type: 'string', name: 'nom_domini'} ] }),
My first problem is that in the first instance, the data does not load into the dataStore, even explicitly indicating: mystore.loadData (my_variable);
Can someone try to tell me what I'm doing wrong? In firebug I get errors like "this.data not defined", "this.reader not defined", or "b is undefined" and "h is undefined".
The same errors occur when I change the data format as a javascript array, for example:
var dataexample = [[1, 'Sant Esteve de Palautordera'], [2, 'Parc Natural del Montseny']];
and call dataexample for the storage property "data".
I am absolutely lost ...