Class Ext.data.JsonReader
Package: | Ext.data |
Class: | JsonReader |
Extends: | Ext.data.DataReader |
Defined In: | JsonReader.js |
Data reader class to create an Array of Ext.data.Record objects from a JSON response
based on mappings in a provided Ext.data.Record constructor.
Example code:
var RecordDef = Ext.data.Record.create([
{name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
{name: 'occupation'} // This field will use "occupation" as the mapping.
]);
var myReader = new Ext.data.JsonReader({
totalProperty: "results", // The property which contains the total dataset size (optional)
root: "rows", // The property which contains an Array of row objects
id: "id" // The property within each row object that provides an ID for the record (optional)
}, RecordDef);
This would consume a JSON file like this:
{ 'results': 2, 'rows': [
{ 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
{ 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
}
Properties
-
Methods
-
Events
-
Config Options
Public Properties
|
jsonData : Object |
JsonReader |
After any data loads, the raw JSON data is available for further custom processing. |
Public Methods
|
JsonReader( Object meta , Object recordType ) |
JsonReader |
Create a new JsonReader |
|
read( Object response ) : Object |
JsonReader |
This method is only used by a DataProxy which has retrieved data from a remote server. |
|
readRecords( Object o ) : Object |
JsonReader |
Create a data block containing Ext.data.Records from an XML document. |
Public Events
This class has no public events.
Config Options
|
id : String |
JsonReader |
Name of the property within a row object that contains a record identifier value. |
|
root : String |
JsonReader |
name of the property which contains the Array of row objects. |
|
successProperty : String |
JsonReader |
Name of the property from which to retrieve the success attribute used by forms. |
|
totalProperty : String |
JsonReader |
Name of the property from which to retrieve the total number of records in the dataset. This is only needed if the wh... |
Property Details
jsonData
public Object jsonData
After any data loads, the raw JSON data is available for further custom processing.
This property is defined by JsonReader.
Constructor Details
JsonReader
public function JsonReader( Object meta
, Object recordType
)
Method Details
read
public function read( Object response
)
This method is only used by a DataProxy which has retrieved data from a remote server.
This method is defined by JsonReader.
readRecords
public function readRecords( Object o
)
Create a data block containing Ext.data.Records from an XML document.
Parameters:
o
: ObjectAn object which contains an Array of row objects in the property specified
in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
which contains the total size of the dataset.
Returns:
This method is defined by JsonReader.
Config Details
id
id : String
Name of the property within a row object that contains a record identifier value.
This config option is defined by JsonReader.
root
root : String
name of the property which contains the Array of row objects.
This config option is defined by JsonReader.
successProperty
successProperty : String
Name of the property from which to retrieve the success attribute used by forms.
This config option is defined by JsonReader.
totalProperty
totalProperty : String
Name of the property from which to retrieve the total number of records in the dataset. This is only needed if the whole dataset is not passed in one go, but is being paged from the remote server.
This config option is defined by JsonReader.