PDA

View Full Version : combobox & store



ayb
4 Aug 2011, 3:16 AM
Hello,

I fill a combobox with a list that I get to java and using dwr.

-monBean.getAll (): returns a list

-In my js file:
Function :



function fct(){
zone=new Array();
monBean.getAll({
callback:function(pReponse){
for (var i = 0; i < pReponse.length; i++) {
zone[i]=new Array();
zone[i]['id_zone'] = pReponse[i].id_zone;
zone[i]['nom_zone'] = pReponse[i].nom_zone;
}

}

storeZone.loadData(zone);



}});}


storeZone



storeZone=new Ext.data.ArrayStore({

fields:['id_zone','nom_zone'],}


Store :When I select my combobox, I find only empty lines


Help plz!

mitchellsimoens
4 Aug 2011, 10:12 AM
The data the ArrayStore is expecting should look like this (in JSON form):


[
[1, 'text'],
[2, 'text'],
[3, 'text'],
[4, 'text']
]

What it looks like you are sending is (in JSON form):


[
{
id_zone : 1,
nom_zone : 'text'
},
{
id_zone : 2,
nom_zone : 'text'
},
{
id_zone : 3,
nom_zone : 'text'
},
{
id_zone : 4,
nom_zone : 'text'
}
]

ayb
4 Aug 2011, 3:00 PM
but I use dwr to get the list.
The expresion "Zone.getAll () returns me a list.
How can I do to fill combobox with the list

Knowing that:

<Zone> List getAll () {
/ / returns the list
}

and attributes of the class "zone" are id_zone and zonename