X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/ee06f37b0f6f6d94cd05a6ffae556660f7c4a2bc..76cb34406ceaf9681a76e13b531d7eafa483ad88:/docs/output/Ext.data.JsonReader.html diff --git a/docs/output/Ext.data.JsonReader.html b/docs/output/Ext.data.JsonReader.html index 5c49b9a2..2894b555 100644 --- a/docs/output/Ext.data.JsonReader.html +++ b/docs/output/Ext.data.JsonReader.html @@ -1,238 +1,113 @@ -
DataReader - JsonReader
Package: | Ext.data |
Defined In: | JsonReader.js |
Class: | JsonReader |
Subclasses: | ArrayReader |
Extends: | DataReader |
-Example code: -
var Employee = Ext.data.Record.create([
- {name: 'firstname'}, // Map the Record's "firstname" field to the row object's key of the same name
- {name: 'job', mapping: 'occupation'} // Map the "job" field to the row object's "occupation" key
+DataReader
JsonReader
Class Ext.data.JsonReader
Package: Ext.data Defined In: JsonReader.js Class: JsonReader Subclasses: ArrayReader Extends: DataReader
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 Employee = Ext.data.Record.create([
+ {name: 'firstname'}, // map the Record's "firstname" field to the row object's key of the same name
+ {name: 'job', mapping: 'occupation'} // map the Record's "job" field to the row object's "occupation" key
]);
-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)
-}, Employee);
-
-This would consume a JSON object of the form:
-
{
- results: 2,
- rows: [
+var myReader = new Ext.data.JsonReader(
+ { // The metadata property, with configuration options:
+ totalProperty: "results", // the property which contains the total dataset size (optional)
+ root: "rows", // the property which contains an Array of record data objects
+ idProperty: "id" // the property within each row object that provides an ID for the record (optional)
+ },
+ Employee // Ext.data.Record constructor that provides mapping for JSON object
+);
+This would consume a JSON data object of the form:
{
+ results: 2, // Reader's configured totalProperty
+ rows: [ // Reader's configured root
{ id: 1, firstname: 'Bill', occupation: 'Gardener' }, // a row object
{ id: 2, firstname: 'Ben' , occupation: 'Horticulturalist' } // another row object
]
}
-It is possible to change a JsonReader's metadata at any time by including a
-metaData property in the data object. If this is detected in the
-object, a Store object using this Reader will reconfigure
-itself to use the newly provided field definition and fire its
-metachange event. In
-undergoing this change, the Store sets its sortInfo property
-from the sortInfo property in the new metadata. Note that reconfiguring a Store
-potentially invalidates objects which may refer to Fields or Records which no longer exist.
-The metaData property may contain any of the configuration
-options for this class. Additionally, it may contain a fields
-property which the JsonReader will use as an argument to Ext.data.Record.create
-to configure the layout of the Records which it will produce.
-Using the metaData property, and the Store's metachange event,
-it is possible to have a Store-driven control initialize itself. The metachange
-event handler may interrogate the metaData property (which
-may contain any user-defined properties needed) and the metaData.fields
-property to perform any configuration required.
-To use this facility to send the same data as the above example without
-having to code the creation of the Record constructor, you would create the
-JsonReader like this:
var myReader = new Ext.data.JsonReader();
-The first data packet from the server would configure the reader by
-containing a metaData property as well as the data:
{
+Automatic configuration using metaData
+It is possible to change a JsonReader's metadata at any time by including a metaData
+property in the JSON data object. If the JSON data object has a metaData property, a
+Store object using this Reader will reconfigure itself to use the newly provided
+field definition and fire its metachange event. The metachange event
+handler may interrogate the metaData property to perform any configuration required.
+Note that reconfiguring a Store potentially invalidates objects which may refer to Fields or Records
+which no longer exist.
+The metaData property in the JSON data object may contain:
+
+- any of the configuration options for this class
+- a fields property which the JsonReader will
+use as an argument to the data Record create method in order to
+configure the layout of the Records it will produce.
+- a sortInfo property which the JsonReader will
+use to set the Ext.data.Store's sortInfo property
+- any user-defined properties needed
+
+To use this facility to send the same data as the example above (without having to code the creation
+of the Record constructor), you would create the JsonReader like this:
var myReader = new Ext.data.JsonReader();
+The first data packet from the server would configure the reader by containing a
+metaData property and the data. For example, the JSON data object might take
+the form:
+{
metaData: {
- totalProperty: 'results',
+ idProperty: 'id',
root: 'rows',
- id: 'id',
+ totalProperty: 'results',
fields: [
{name: 'name'},
- {name: 'occupation'}
- ]
+ {name: 'job', mapping: 'occupation'}
+ ],
+ sortInfo: {field: 'name', direction:'ASC'}, // used by store to set its sortInfo
+ foo: 'bar' // custom property
},
results: 2,
- rows: [
+ rows: [ // an Array
{ 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
{ 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' }
]
-}
-
-
-
- Config Options
-
- Public Properties
-
- Public Methods
-
-
- Method
- Defined By
-
-
-
-
-
- JsonReader( Object meta
, Object recordType
)
- Create a new JsonReader
-
- Create a new JsonReader
- Parameters:
- meta
: ObjectMetadata configuration options.recordType
: ObjectEither an Array of field definition objects as passed to
-Ext.data.Record.create, or a Record constructor created using Ext.data.Record.create.
- Returns:
-
-
-
-
-
-
-
- JsonReader
-
-
-
-
-
- read( Object response
) : Object
-
-This method is only used by a DataProxy which has retrieved data from a remote server.
-
-
-This method is only used by a DataProxy which has retrieved data from a remote server.
- Parameters:
- response
: ObjectThe XHR object which contains the JSON data in its responseText.
- Returns:
-
- Object
data A data block which is used by an Ext.data.Store object as a cache of Ext.data.Records.
-
-
-
-
-
- JsonReader
-
-
-
-
-
- readRecords( Object o
) : Object
- Create a data block containing Ext.data.Records from a JSON object.
-
- Create a data block containing Ext.data.Records from a JSON object.
- Parameters:
- o
: ObjectAn object which contains an Array of row objects in the property specified
+}Config Options
Config Options Defined By fields : Array/ObjectEither an Array of Field definition objects (which
+will be passed to Ext.data.Record.create, or a Record
+constructo...Either an Array of Field definition objects (which
+will be passed to Ext.data.Record.create, or a Record
+constructor created from Ext.data.Record.create.
DataReader idProperty : String[id] Name of the property within a row object that contains a record identifier value. Defaults to id JsonReader root : String[undefined] Required. The name of the property
+which contains the Array of row objects. Defaults to undefined.
+An e...[undefined] Required. The name of the property
+which contains the Array of row objects. Defaults to undefined.
+An exception will be thrown if the root property is undefined. The data packet
+value for this property should be an empty array to clear the data or show
+no data. JsonReader successProperty : String[success] Name of the property from which to
+retrieve the success attribute. Defaults to success. See
+Ext.data.DataP...[success] Name of the property from which to
+retrieve the success attribute. Defaults to success. See
+Ext.data.DataProxy.exception
+for additional information. JsonReader totalProperty : String[total] Name of the property from which to retrieve the total number of records
+in the dataset. This is only needed i...[total] 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. Defaults to total. JsonReader
Public Properties
Property Defined By buildExtractors : ObjectAbstract method, overridden in Ext.data.JsonReader DataReader jsonData : ObjectAfter any data loads, the raw JSON data is available for further custom processing. If no data is
+loaded or there is...After any data loads, the raw JSON data is available for further custom processing. If no data is
+loaded or there is a load exception this property will be undefined. JsonReader meta : MixedThis JsonReader's metadata as passed to the constructor, or as passed in
+the last data packet's metaData property. JsonReader
Public Methods
Method Defined By JsonReader( Object meta
, Array/Object recordType
)
+ Create a new JsonReaderCreate a new JsonReaderParameters:meta
: ObjectMetadata configuration options.recordType
: Array/ObjectEither an Array of Field definition objects (which
+will be passed to Ext.data.Record.create, or a Record
+constructor created from Ext.data.Record.create.
Returns:- void
JsonReader isData( Object data
)
+ :
+ BooleanReturns true if the supplied data-hash looks and quacks like data. Checks to see if it has a key
+corresponding to i...Returns true if the supplied data-hash looks and quacks like data. Checks to see if it has a key
+corresponding to idProperty defined in your DataReader config containing non-empty pk.Parameters:data
: Object
Returns:Boolean
DataReader read( Object response
)
+ :
+ ObjectThis method is only used by a DataProxy which has retrieved data from a remote server.This method is only used by a DataProxy which has retrieved data from a remote server.Parameters:response
: ObjectThe XHR object which contains the JSON data in its responseText.
Returns:Object
data A data block which is used by an Ext.data.Store object as
+a cache of Ext.data.Records.
JsonReader readRecords( Object o
)
+ :
+ ObjectCreate a data block containing Ext.data.Records from a JSON object.Create a data block containing Ext.data.Records from a JSON object.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:
-
- Object
data A data block which is used by an Ext.data.Store object as a cache of Ext.data.Records.
-
-
-
-
-
- JsonReader
-
-
-
- Public Events
- This class has no public events.
-
\ No newline at end of file
+which contains the total size of the dataset.Returns:Object
data A data block which is used by an Ext.data.Store object as
+a cache of Ext.data.Records.
JsonReader readResponse( String action
, Object response
)
+ :
+ voidDecode a json response from server.Decode a json response from server.Parameters:action
: String[Ext.data.Api.actions.create|read|update|destroy]response
: Object
Returns:- void
JsonReader realize( Record/Record[] record
, Object/Object[] data
)
+ :
+ voidUsed for un-phantoming a record after a successful database insert. Sets the records pk along with new data from ser...Used for un-phantoming a record after a successful database insert. Sets the records pk along with new data from server.
+You must return at least the database pk using the idProperty defined in your DataReader configuration. The incoming
+data from server will be merged with the data in the local record.
+In addition, you must return record-data from the server in the same order received.
+Will perform a commit as well, un-marking dirty-fields. Store's "update" event will be suppressed.Parameters:record
: Record/Record[]The phantom record to be realized.data
: Object/Object[]The new record data to apply. Must include the primary-key from database defined in idProperty field.
Returns:- void
DataReader update( Record/Record[] rs
, Object/Object[] data
)
+ :
+ voidUsed for updating a non-phantom or "real" record's data with fresh data from server after remote-save.
+If returning ...Used for updating a non-phantom or "real" record's data with fresh data from server after remote-save.
+If returning data from multiple-records after a batch-update, you must return record-data from the server in
+the same order received. Will perform a commit as well, un-marking dirty-fields. Store's "update" event will be
+suppressed as the record receives fresh new data-hashParameters:rs
: Record/Record[]data
: Object/Object[]
Returns:- void
DataReader
Public Events
This class has no public events.
\ No newline at end of file