PDA

View Full Version : ComboBox with JsonStore not displaying text of entries but entries exist



aaronbartell
1 Jul 2010, 6:00 AM
I am using ExtJS 3.2.1 and am having an issue when populating Ext.form.ComboBox with a Ext.data.JsonStore. The JsonStore receives the data from the server fine and without error, but when I click the expand button on the ComboBox it just shows skinny empty entries where there should be text values. I have this working with another customer and have tripple checked to see where the issue might be. I think I might just need another set of eyes.

Here is the simple page:


Ext.onReady(function(){

store1 = new Ext.data.JsonStore({
autoLoad:true,
proxy: new Ext.data.HttpProxy({url:'/rpgui/ldlst', method:'POST'}),
baseParams: {action:'FN4110', MNAM:'', TCDE:'MS'},
root: 'list',
fields: ['vfld','dfld']
});

var fp = new Ext.FormPanel({
title:'Form Title',
items:[
new Ext.form.ComboBox({
store:store1,
valueField:'vfld',
displayField:'dfld',
triggerAction:'all',
})
]
});

fp.render(document.body);

});

Here is the raw JSON returned from the server:


{ "list":[ { "D":"Divorced" } , { "DP":"Domestic Partner" } , { "M":"Married" } , { "S":"Single" } , { "SE":"Separated" } , { "W":"Widow/Widower" } ] , "success":true , "msg":" " }

If I do a Ext.data.SimpleStore then there are values in the ComboBox:

new Ext.form.ComboBox({
store: new Ext.data.SimpleStore({
fields: ['key', 'value'],
data: [['D', 'Divorced'],['DP', 'Domestic Parnter'],
['M', 'Married'],['S', 'Single'],
['SE', 'Separated'],['W', 'Window/Windower']]
}),
valueField:'key',
displayField:'value',
mode:'local',
triggerAction:'all',
})

Thanks for any help,
AaronBartell.com
RPG+DB2+IBMi+ExtJS=Goodness

mankz
1 Jul 2010, 6:10 AM
Your json should look like (based on your fields):



{ "list":[ { "vfld": "D", "dfld" : "Divorced" } , { "vfld": "DP", "dfld" :"Domestic Partner" }, ....

fay
1 Jul 2010, 6:12 AM
You're missing "mode: 'local'" from your first config. Also, watch out for trailing commas: "triggerAction:'all',"

EDIT: And, more importantly, what mankz ^^ says :)

aaronbartell
1 Jul 2010, 6:32 AM
Your json should look like (based on your fields):



{ "list":[ { "vfld": "D", "dfld" : "Divorced" } , { "vfld": "DP", "dfld" :"Domestic Partner" }, ....


My goodness do I feel stupid. Thanks for the quick response. It is now working. The difference from my previous implementation of this is that I was only passing back a single entry in each array element (i.e. only a displayField value and not a valueField value).

Thx again,
AaronBartell.com
RPG+DB2+IBMi+ExtJS=Goodness