Ext. Data. dataproxy
The data proxy class is a pure virtual class that is mainly used to generate Ext. Data. Record objects. There are no public attributes and methods, but three events need to be processed in the stator class.
Beforeload: (object this, object Params)
Load: (object this, object o, object Arg)
Loadexception: (object this, object o, object Arg, Object E)
In fact, the parameter is also customized by the subclass.
Ext. Data. httpproxy
In the API documentation, httpproxy is inherited from the object. In fact, both the source and Ext. Data. memoryproxy and Ext. Data. scripttagproxy inherit from dataproxy.
Httpproxy is used for remote proxy, and the Content-Type attribute must be set to "text/XML" when the server returns information ".
Httpproxy (Object conn)
Construct an httpproxy object. The parameter can be similar to {URL: 'foo. a json object like php'} can also be an ext. data. connection object. If the parameter is not specified, ext. ajax object will be used to initiate a request
Getconnection (): Connection
Get the current connection object
Load (Object Params, ext. Data. datareader reader, function callback, object scope, object Arg): void
Obtain the record data block from the configured connection object and run callback.
Params: parameters to be passed to the server when an HTTP request is initiated
Datareader: see datareader
Callback: Call back method. The first parameter is the received information, the second parameter is Arg, and the third parameter is the success mark.
Scope: Range
Arg: The parameter here will be passed to the call back function callback.
Example:
VaR proxy = new Ext. Data. httpproxy ({URL: 'datasource. xml '});
// Reader will be explained in Ext. Data. datareader
VaR reader = new Ext. Data. xmlreader ({
Totalrecords: "Results ",
Record: "row ",
ID: "ID"
},[
{Name: 'name', mapping: 'name '},
{Name: 'occupation '}
]);
// Define the call back method
VaR metadata;
Function callback (data, ARG, success ){
If (SUCCESS ){
Metadata = data;
}
}
// Use reader to convert the returned XML file into metadata from the URL configured by connection, and pass it to callback
Proxy. Load (null, reader, callback, this );
Ext. Data. memoryproxy
Memoryproxy (Object Data)
Structure
Load (Object Params, ext. Data. datareader reader, function callback, object scope, object Arg): void
Data retrieval is similar to httpproxy, but the Params parameter is not used.
Example
VaR proxy = new Ext. Data. memoryproxy ([[1, 'bill ', 'gardener'], [2, 'ben', 'horticulturalist']);
VaR reader = new Ext. Data. arrayreader (
{ID: 0 },
[
{Name: 'name', mapping: 1 },
{Name: 'occupation', mapping: 2}
]);
VaR metadata;
Function callback (data, ARG, success ){
Metadata = data;
}
Proxy. Load (null, reader, callback, this );
Ext. Data. scripttagproxy
Similar to httpproxy, this class is also used to request remote data, but can be used for cross-primary domain calls. If the callback parameter is used in the request
The server should specify the Content-Type attribute as "text/JavaScript"
And return callback (jsonobject)
Otherwise, set the Content-Type attribute to "application/X-JSON"
And directly return the JSON object
Scripttagproxy (Object config)
Structure, where
Config is defined {
Callbackparam: String, // call back Parameter
Nocache: Boolean, // whether to cache
Timeout: Number, // timeout
URL: String // the URL of the request data
}
Abort (): void
Give up
Load (Object Params, ext. Data. datareader reader, function callback, object scope, object Arg): void