Ext.NET  5.3.0
.NET Component Framework for Enterprise Level Apps
Ext.Net.AbstractReader Class Reference

Readers are used to interpret data to be loaded into a Model instance or a Store - usually in response to an AJAX request. This is normally handled transparently by passing some configuration to either the Model or the Store in question - see their documentation for further details. More...

Inheritance diagram for Ext.Net.AbstractReader:
Ext.Net.BaseItem Ext.Net.IAlias Ext.Net.IXObject Ext.Net.IBase Ext.Net.JsonReader Ext.Net.XmlReader Ext.Net.ArrayReader Ext.Net.ODataReader

Classes

class  Builder
 
class  Config
 

Public Member Functions

virtual void SetGroupRootProperty (string groupRootProperty)
 Sets the value of groupRootProperty. More...
 
virtual void SetSummaryRootProperty (string summaryRootProperty)
 Sets the value of summaryRootProperty. More...
 
virtual void SetMessageProperty (string messageProperty)
 Sets the value of messageProperty. More...
 
virtual void SetMessageProperty (JFunction messageProperty)
 Sets the value of messageProperty. More...
 
- Public Member Functions inherited from Ext.Net.BaseItem
virtual bool HasExplicitValue (string name)
 
void EnsureDataBind ()
 
virtual void Call (string name)
 
virtual void Call (string name, params object[] args)
 
virtual void AddScript (string script)
 
virtual void AddScript (string script, params object[] args)
 
virtual bool IsEmptyObject ()
 
Apply< T > (IApply config)
 
BaseItem Apply (object config)
 
virtual void LoadViewState (object state)
 
virtual object SaveViewState ()
 
virtual void TrackViewState ()
 
void SetDirty ()
 
virtual void DataBind ()
 
virtual IControlBuilder ToNativeBuilder ()
 

Properties

override string InstanceOf [get]
 
abstract string Type [get]
 Alias More...
 
virtual string GroupRootProperty [get, set]
 Name of the property from which to retrieve remote grouping summary information. More...
 
virtual string IDProperty [get, set]
 Name of the property within a row object that contains a record identifier value. Defaults to The id of the model. If an idProperty is explicitly specified it will override that of the one specified on the model More...
 
virtual bool ImplicitIncludes [get, set]
 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. More...
 
virtual ? bool? KeepRawData [get, set]
 Determines if the Reader will keep raw data received from the server in the rawData property. While this might seem useful to do additional data processing, keeping raw data might cause adverse effects such as memory leaks. It is recommended to set keepRawData to false if you do not need the raw data. If you need to process data packet to extract additional data such as row summaries, it is recommended to use transform function for that purpose. Defaults to: true More...
 
virtual bool ReadRecordsOnFailure [get, set]
 True to read extract the records from a data packet even if the success property returns false. Defaults to: true More...
 
virtual string RootProperty [get, set]
 The name of the property which contains the Array of row objects. For JSON reader it's dot-separated list of property names. For XML reader it's a CSS selector. For array reader it's not applicable. By default the natural root of the data will be used. The root Json array, the root XML element, or the array. The data packet value for this property should be an empty array to clear the data or show no data. Defaults to: "" More...
 
virtual string SuccessProperty [get, set]
 Name of the property from which to retrieve the success attribute. Defaults to success. See Ext.data.proxy.Proxy.exception for additional information. More...
 
virtual string SummaryRootProperty [get, set]
 Name of the property from which to retrieve remote summary information. More...
 
virtual string TotalProperty [get, set]
 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. More...
 
virtual TransformFunction Transform [get]
 If a transform function is set, it will be invoked just before readRecords executes. It is passed the raw (deserialized) data object. The transform function returns a data object, which can be a modified version of the original data object, or a completely new data object. The transform can be a function, or an object with a 'fn' key and an optional 'scope' key. More...
 
virtual string TransformProxy [get]
 A proxy to render .Transform to client More...
 
virtual string TypeProperty [get, set]
 The name of the property in a node raw data block which indicates the type of the model to be created from that raw data. Useful for heterogenous trees. For example, hierarchical geographical data may look like this: { nodeType: 'Territory', name: 'EMEA', children: [{ nodeType: 'Country', name: 'United Kingdon', children: [{ nodeType: 'City', name: 'London' }] }] } More...
 
virtual string MessageProperty [get, set]
 The name of the property which contains a response message for exception handling. More...
 
virtual JFunction MessagePropertyFn [get, set]
 The name of the property which contains a response message for exception handling. More...
 
virtual string ModelName [get, set]
 The Ext.data.Model associated with this reader More...
 
string PropertyName [get]
 
override ConfigOptionsCollection ConfigOptions [get]
 
- Properties inherited from Ext.Net.BaseItem
virtual string InstanceOf [get]
 
ItemState State [get]
 
virtual DefaultValueMode DefaultValueMode [get, set]
 
virtual bool DesignMode [get]
 
bool AutoDataBind [get, set]
 
ResourceManager ResourceManager [get]
 
virtual Control Owner [get, set]
 The Owner Control for this Listener. More...
 
virtual bool IsDefault [get]
 Does this object currently represent it's default state. More...
 
bool IsTrackingViewState [get]
 
EventHandlerList Events [get]
 
EventHandler DataBinding
 
Control?? BindingContainer [get]
 
virtual ConfigItemCollection?? CustomConfig [get]
 Collection of custom js config More...
 
virtual ConfigOptionsCollection ConfigOptions [get]
 
virtual ConfigOptionsExtraction ConfigOptionsExtraction [get]
 
System.Web.Mvc.HtmlHelper?? HtmlHelper [get, set]
 
- Properties inherited from Ext.Net.IXObject
ConfigOptionsCollection ConfigOptions [get]
 
ConfigOptionsExtraction ConfigOptionsExtraction [get]
 
DefaultValueMode DefaultValueMode [get, set]
 
- Properties inherited from Ext.Net.IAlias
string PropertyName [get]
 

Additional Inherited Members

- Protected Member Functions inherited from Ext.Net.BaseItem
 BaseItem (Control owner)
 
 BaseItem ()
 
virtual void OwnerUpdate (Control owner)
 
virtual void OnDataBinding (EventArgs e)
 

Detailed Description

Readers are used to interpret data to be loaded into a Model instance or a Store - usually in response to an AJAX request. This is normally handled transparently by passing some configuration to either the Model or the Store in question - see their documentation for further details.

Loading Nested Data

Readers have the ability to automatically load deeply-nested data objects based on the associations configured on each Model. Below is an example demonstrating the flexibility of these associations in a fictional CRM system which manages a User, their Orders, OrderItems and Products. First we'll define the models:

Ext.regModel("User", { fields: [ 'id', 'name' ],

hasMany: {model: 'Order', name: 'orders'},

proxy: { type: 'rest', url : 'users.json', reader: { type: 'json', root: 'users' } } });

Ext.regModel("Order", { fields: [ 'id', 'total' ],

hasMany : {model: 'OrderItem', name: 'orderItems', associationKey: 'order_items'}, belongsTo: 'User' });

Ext.regModel("OrderItem", { fields: [ 'id', 'price', 'quantity', 'order_id', 'product_id' ],

belongsTo: ['Order', {model: 'Product', associationKey: 'product'}] });

Ext.regModel("Product", { fields: [ 'id', 'name' ],

hasMany: 'OrderItem' }); This may be a lot to take in - basically a User has many Orders, each of which is composed of several OrderItems. Finally, each OrderItem has a single Product. This allows us to consume data like this:

{ "users": [ { "id": 123, "name": "Ed", "orders": [ { "id": 50, "total": 100, "order_items": [ { "id" : 20, "price" : 40, "quantity": 2, "product" : { "id": 1000, "name": "MacBook Pro" } }, { "id" : 21, "price" : 20, "quantity": 3, "product" : { "id": 1001, "name": "iPhone" } } ] } ] } ] } The JSON response is deeply nested - it returns all Users (in this case just 1 for simplicity's sake), all of the Orders for each User (again just 1 in this case), all of the OrderItems for each Order (2 order items in this case), and finally the Product associated with each OrderItem. Now we can read the data and use it as follows:

var store = new Ext.data.Store({ model: "User" });

store.load({ callback: function() { //the user that was loaded var user = store.first();

console.log("Orders for " + user.get('name') + ":")

//iterate over the Orders for each User user.orders().each(function(order) { console.log("Order ID: " + order.getId() + ", which contains items:");

//iterate over the OrderItems for each Order order.orderItems().each(function(orderItem) { //we know that the Product data is already loaded, so we can use the synchronous getProduct //usually, we would use the asynchronous version (see Ext.data.BelongsToAssociation) var product = orderItem.getProduct();

console.log(orderItem.get('quantity') + ' orders of ' + product.get('name')); }); }); } }); Running the code above results in the following:

Orders for Ed: Order ID: 50, which contains items: 2 orders of MacBook Pro 3 orders of iPhone

Member Function Documentation

◆ SetGroupRootProperty()

virtual void Ext.Net.AbstractReader.SetGroupRootProperty ( string  groupRootProperty)
inlinevirtual

Sets the value of groupRootProperty.

Parameters
groupRootPropertyThe new value.

◆ SetMessageProperty() [1/2]

virtual void Ext.Net.AbstractReader.SetMessageProperty ( JFunction  messageProperty)
inlinevirtual

Sets the value of messageProperty.

Parameters
messagePropertyThe new value.

◆ SetMessageProperty() [2/2]

virtual void Ext.Net.AbstractReader.SetMessageProperty ( string  messageProperty)
inlinevirtual

Sets the value of messageProperty.

Parameters
messagePropertyThe new value.

◆ SetSummaryRootProperty()

virtual void Ext.Net.AbstractReader.SetSummaryRootProperty ( string  summaryRootProperty)
inlinevirtual

Sets the value of summaryRootProperty.

Parameters
summaryRootPropertyThe new value.

Property Documentation

◆ ConfigOptions

override ConfigOptionsCollection Ext.Net.AbstractReader.ConfigOptions
get

◆ GroupRootProperty

virtual string Ext.Net.AbstractReader.GroupRootProperty
getset

Name of the property from which to retrieve remote grouping summary information.

◆ IDProperty

virtual string Ext.Net.AbstractReader.IDProperty
getset

Name of the property within a row object that contains a record identifier value. Defaults to The id of the model. If an idProperty is explicitly specified it will override that of the one specified on the model

◆ ImplicitIncludes

virtual bool Ext.Net.AbstractReader.ImplicitIncludes
getset

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.

◆ InstanceOf

override string Ext.Net.AbstractReader.InstanceOf
get

◆ KeepRawData

virtual ? bool? Ext.Net.AbstractReader.KeepRawData
getset

Determines if the Reader will keep raw data received from the server in the rawData property. While this might seem useful to do additional data processing, keeping raw data might cause adverse effects such as memory leaks. It is recommended to set keepRawData to false if you do not need the raw data. If you need to process data packet to extract additional data such as row summaries, it is recommended to use transform function for that purpose. Defaults to: true

◆ MessageProperty

virtual string Ext.Net.AbstractReader.MessageProperty
getset

The name of the property which contains a response message for exception handling.

◆ MessagePropertyFn

virtual JFunction Ext.Net.AbstractReader.MessagePropertyFn
getset

The name of the property which contains a response message for exception handling.

◆ ModelName

virtual string Ext.Net.AbstractReader.ModelName
getset

The Ext.data.Model associated with this reader

◆ PropertyName

string Ext.Net.AbstractReader.PropertyName
get

◆ ReadRecordsOnFailure

virtual bool Ext.Net.AbstractReader.ReadRecordsOnFailure
getset

True to read extract the records from a data packet even if the success property returns false. Defaults to: true

◆ RootProperty

virtual string Ext.Net.AbstractReader.RootProperty
getset

The name of the property which contains the Array of row objects. For JSON reader it's dot-separated list of property names. For XML reader it's a CSS selector. For array reader it's not applicable. By default the natural root of the data will be used. The root Json array, the root XML element, or the array. The data packet value for this property should be an empty array to clear the data or show no data. Defaults to: ""

◆ SuccessProperty

virtual string Ext.Net.AbstractReader.SuccessProperty
getset

Name of the property from which to retrieve the success attribute. Defaults to success. See Ext.data.proxy.Proxy.exception for additional information.

◆ SummaryRootProperty

virtual string Ext.Net.AbstractReader.SummaryRootProperty
getset

Name of the property from which to retrieve remote summary information.

◆ TotalProperty

virtual string Ext.Net.AbstractReader.TotalProperty
getset

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.

◆ Transform

virtual TransformFunction Ext.Net.AbstractReader.Transform
get

If a transform function is set, it will be invoked just before readRecords executes. It is passed the raw (deserialized) data object. The transform function returns a data object, which can be a modified version of the original data object, or a completely new data object. The transform can be a function, or an object with a 'fn' key and an optional 'scope' key.

Example usage:

Ext.create('Ext.data.Store', { model: 'User', proxy: { type: 'ajax', url : 'users.json', reader: { type: 'json', transform: { fn: function(data) { // do some manipulation of the raw data object return data; }, scope: this } } } });

◆ TransformProxy

virtual string Ext.Net.AbstractReader.TransformProxy
getprotected

A proxy to render .Transform to client

◆ Type

abstract string Ext.Net.AbstractReader.Type
getprotected

Alias

◆ TypeProperty

virtual string Ext.Net.AbstractReader.TypeProperty
getset

The name of the property in a node raw data block which indicates the type of the model to be created from that raw data. Useful for heterogenous trees. For example, hierarchical geographical data may look like this: { nodeType: 'Territory', name: 'EMEA', children: [{ nodeType: 'Country', name: 'United Kingdon', children: [{ nodeType: 'City', name: 'London' }] }] }

You would configure the typeProperty in this case to be "nodeType" which would cause the models named "Territory", "Country" and "City" to be used. Defaults to: ''


The documentation for this class was generated from the following files: