Clear Up
SharpKit Reference

Reader Class

Namespace: Ext.data.reader

Base Types

System.Object

Constructors

Name Description
Reader()
Reader(ReaderConfig)
Reader(object) Creates new Reader. @param {Object} config (optional) Config object.

Methods

Name Description
buildExtractors(bool) @private This builds optimized functions for retrieving record data and meta data from an object. Subclasses may need to implement their own getRoot function. @param {Boolean} force True to automatically remove existing extractor functions first (defaults to false)
buildFieldExtractors() @private
extractData(object) Returns extracted, type-cast rows of data. Iterates to call #extractValues for each row @param {Object[]/Object} root from server response @private
extractValues(object) @private Given an object representing a single model instance's data, iterates over the model's fields and builds an object with the value for each field. @param {Object} data The data object to convert @return {Object} Data object suitable for use with a model constructor
getAssociatedDataRoot(object, JsString) @private Used internally by {@link #readAssociated}. Given a data object (which could be json, xml etc) for a specific record, this should return the relevant part of that data for the given association name. This is only really needed to support the XML Reader, which has to do a query to get the associated data object @param {Object} data The raw data object @param {String} associationName The name of the association to get data for (uses associationKey if present) @return {Object} The root
getData(object) @private By default this function just returns what is passed to it. It can be overridden in a subclass to return something else. See XmlReader for an example. @param {Object} data The data object @return {Object} The normalized data object
getFields()
getIdProperty() Get the idProperty to use for extracting data @private @return {String} The id property
getResponseData(object) Takes a raw response object (as passed to this.read) and returns the useful data segment of it. This must be implemented by each subclass @param {Object} response The responce object @return {Object} The useful data from the response
getRoot(object) @private This will usually need to be implemented in a subclass. Given a generic data object (the type depends on the type of data we are reading), this function should return the object as configured by the Reader's 'root' meta data config. See XmlReader's getRoot implementation for an example. By default the same data object will simply be returned. @param {Object} data The data object @return {Object} The same data object
onMetaChange(object) @private Reconfigures the meta data tied to this Reader
read(object) Reads the given response object. This method normalizes the different types of response object that may be passed to it, before handing off the reading of records to the {@link #readRecords} function. @param {Object} response The response object. This may be either an XMLHttpRequest object or a plain JS object @return {Ext.data.ResultSet} The parsed ResultSet object
readAssociated(Model, object) @private Loads a record's associations from the data object. This prepopulates hasMany and belongsTo associations on the record provided. @param {Ext.data.Model} record The record to load associations for @param {Object} data The data object @return {String} Return value description
readRecords(object) Abstracts common functionality used by all Reader subclasses. Each subclass is expected to call this function before running its own logic and returning the Ext.data.ResultSet instance. For most Readers additional processing should not be needed. @param {Object} data The raw data object @return {Ext.data.ResultSet} A ResultSet object
setModel(object, bool) Sets a new model for the reader. @private @param {Object} model The model to set. @param {Boolean} setOnProxy True to also set on the Proxy, if one is configured

Properties

Name Description
IdProperty Get the idProperty to use for extracting data @private @return {String} The id property
implicitIncludes @cfg {Boolean} implicitIncludes True to automatically parse models nested within other models in a response object. See the Ext.data.reader.Reader intro docs for full explanation. Defaults to true.
isReader @cfg {Boolean} implicitIncludes True to automatically parse models nested within other models in a response object. See the Ext.data.reader.Reader intro docs for full explanation. Defaults to true.
root @cfg {String} root **(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.
successProperty @cfg {String} successProperty Name of the property from which to retrieve the success attribute. Defaults to success. See {@link Ext.data.proxy.Server}.{@link Ext.data.proxy.Server#exception exception} for additional information.
totalProperty @cfg {String} totalProperty 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.
© Copyright 2005-2011 SharpKit. All rights reserved.