PDA

View Full Version : ExtDesigner, ComboBox and JsonStore



slacker775
22 May 2010, 10:45 AM
I've created a simple form w/ ED that has two ComboBoxes pulling from a JsonStore (all defined w/ ED). I have it all running via my web server but when I activate the combo to populate, it makes the call to the server, gets the proper JSON response, but nothing winds up in the combo itself. I've tried flipping all kinds of settings around to no avail. I'm pretty certain it's just something stupid that I am overlooking, but I can't find it for the life of me.

Here's the relevant bits of code:

JsonStore:


TEX.store.Office = Ext.extend(Ext.data.JsonStore, {
constructor: function(cfg) {
cfg = cfg || {};
TEX.store.Office.superclass.constructor.call(this, Ext.apply({
storeId: 'locationStore',
root: 'locations',
url: '/location/list',
totalProperty: 'total',
idProperty: 'locationid'
}, cfg));
}
});
new TEX.store.Office();

ComboBox def in the form

{
xtype: 'combo',
fieldLabel: 'Office',
anchor: '100%',
name: 'office',
store: 'locationStore',
triggerAction: 'all',
valueField: 'locationid',
displayField: 'name',
id: 'office'
}


Json Response when I activate the combo

{"locations":[{"locationid":6,"name":"Atlanta"},{"locationid":13,"name":"Boston"},{"locationid":3,"name":"Calgary"},{"locationid":11,"name":"Dallas"},{"locationid":5,"name":"London"},{"locationid":14,"name":"Phoenix"},{"locationid":15,"name":"Raleigh"},{"locationid":2,"name":"South Florida"},{"locationid":1,"name":"Tampa"},{"locationid":4,"name":"Toronto"},{"locationid":12,"name":"Vancouver"}],"total":11}

slacker775
25 May 2010, 5:31 AM
As a quick follow-up, some debugging has turned up that part of my problem is in the readRecords() method in the JsonReader. Some extra, unused variables were tossing an exception. That bug is apparently fixed in svn but now I might be dying further down in the call to extractData().

jarrednicholls
25 May 2010, 6:04 AM
I don't see any fields defined in your JsonStore. I'd expect to see this:



TEX.store.Office = Ext.extend(Ext.data.JsonStore, {
constructor: function(cfg) {
cfg = cfg || {};
TEX.store.Office.superclass.constructor.call(this, Ext.apply({
storeId: 'locationStore',
root: 'locations',
url: '/location/list',
totalProperty: 'total',
idProperty: 'locationid',
fields: [
{
name: 'locationid'
},
{
name: 'name'
}
]
}, cfg));
}
});
new TEX.store.Office();

slacker775
26 May 2010, 3:40 AM
Argh... Adding the fields config took care of it. Are there plans to add the ability to configure the fields for the store in the Designer? Maybe an auto-populate capability based on the fields returned?

jarrednicholls
26 May 2010, 7:04 AM
Actually yes, you'll be happy to hear that there is :-)