View Full Version : JsonStore for a single record?

11 Aug 2009, 11:25 AM
Is it possible for a JsonStore to only anticipate a single record? I want to handle JSON packets like this one:

{'site': {'attr': 'value', 'attr2': 'value'}}

If not, what do I have to do, client or server side, to smoothly pass a single record into Ext3?

12 Aug 2009, 6:14 AM
Even if you have only 1 record, JsonStore still expects an array.

12 Aug 2009, 6:31 AM
Yea, when I thought about it, it made more sense to just fetch the single record with a standard Ext request rather than using a reader.

27 Apr 2011, 8:35 AM
Can you please post an example of how to fetch a single json record using an Ext request?


27 Apr 2011, 8:47 AM
An Ext.Ajax.request() has no notion of what a 'record' is, it's only concerned with some block of data.

If you're dealing with a Grid/JsonStore, then keep things within the context of a store.

If you just want an Ext.Ajax.request() to pull back a chunk o' JSON:

url: 'someUrl',
method: 'GET',
// params: {
// someParam: 'someValue'
// },
success: function(result, request) {
var json = Ext.decode(result.responseText);
Ext.Msg.alert('Response', 'site.attr == ' + json.site.attr);
failure: function(result, request) {
Ext.Msg.alert('Error!', 'Some bad mojo on the server side...');

28 Apr 2011, 2:57 AM
This was exactly what I needed! :-)