Proxy data proxy for extjs4

Source: Internet
Author: User
Tags sessionstorage
ArticleDirectory
    • 1. Ext. Data. Proxy. Proxy
    • 5. Ext. Data. Proxy. localstorage
    • 6. Ext. Data. Proxy. sessionstorage
    • 7. Ext. Data. Proxy. Server

Proxy data proxy is the only way to perform data read/write operations. The data proxy classes provided by extjs include Ext. data. proxy. client client proxy and ext. data. proxy. server proxy, all of which are inherited from ext. data. proxy. proxy class. The sub-classes of client proxy and server proxy are as follows, with seven public classes.

Client proxy:

Ext. Data. Proxy. menory, ext. Data. Proxy. webstorage, ext. Data. Proxy. localstorage, ext. Data. Proxy. sessionstorage

Server Proxy:

Ext. Data. Proxy. Ajax, ext. Data. Proxy. Rest, ext. Data. Proxy. jsonp

1. Ext. Data. Proxy. Proxy

Ext. data. proxy. proxy is the parent class of all proxy classes. It defines the basic behavior and interfaces of the proxy. The basic principle of operating data through proxy is to execute create (create), read (read) update and delete operations are mapped to the four functions create, read, update, and destory. Ext. data. proxy. each subclass of proxy needs to implement these functions separately, and each crud method will obtain a unique Ext. data. the operation object is used as a parameter, which encapsulates the detailed content of the operation. In addition, each crud method can specify a callback function to process the data. The following table lists the main configuration items supported by the Ext. Data. Proxy. proxy class.

Table 1-1 main configuration items of Ext. Data. Proxy. Proxy

Configuration item Parameter type Description
Batchactions Boolean Sets whether to Perform Batch operations. The default value is true.
Batchorder String Sets the sequence of batch operations. The default value is 'create, update, destory'
Model String/EXT. Data. Model Set the name or reference of the model class to be supported by the proxy
2. Ext. Data. Proxy. Client

Ext. data. proxy. the client is the base class for data storage operations on the client. Generally, it is not instantiated directly, but uses its two subclasses: ext. data. proxy. memory proxy and ext. data. proxy. webstorage browser storage proxy.

3. Ext. Data. Proxy. menory

Ext. Data. Proxy. menory is a simple data proxy that uses memory variables to access data. Therefore, data is lost after every page refresh. Its main method is as follows:

Configuration item

Parameter type Description
Data Array Configure the record array for reading
4. Ext. Data. Proxy. webstorage

Ext. data. proxy. webstorage is a simple parent class for browser client storage proxy. It depends on the new Dom Storage Feature of html5. this feature supports Web applications with offline functions of development tools, although the browser currently supports storing data with cookies, the cookie length is very small and has limited functions.

Configuration item

Parameter type Description
ID String Uniquely identifies a data storage area on a browser client.

 

Dom storage is divided into two types: sessionstorage and localstorage. Their main differences are as follows:

Sessionstorage: used to store data associated with the current browser window. After the window is closed, the data stored in sessionstorage will not be available.

Localstorage: because data is stored for a long time. After the window is closed, the data in localstorage can still be accessed, and all browser windows can share the data in localstorage.

5. Ext. Data. Proxy. localstorage

Ext. data. proxy. localstorage is Ext. data. proxy. A subclass of webstorage. It uses the localstorage API of HTML 5 to save data on the client, because the localstorage of HTML 5 cannot store complex data, the localstorage agent automatically serializes and deserializes data during read/write operations.

Localstorage proxy is often used to save user information that does not need to be stored on the server. This write information does not disappear after the browser is closed and can be saved for a long time.

Because the localstorage API of HTML 5 stores all data in a single shared namespace, you must specify a unique ID for the localstorage agent to distinguish different types of business data, you can use a unique ID proxy to effectively manage data.

6. Ext. Data. Proxy. sessionstorage

Ext. data. proxy. sessionstorage is Ext. data. proxy. webstorage subclass, which uses the localstorage API of HTML 5 to save data on the client. data. proxy. the difference between localstorage and localstorage is that when the browser is closed, data will be lost, and it is not suitable for long-term data storage. In addition, it is used in the same way as the localstorage proxy.

7. Ext. Data. Proxy. Server

Ext. data. proxy. server is the parent class of the server proxy. It is generally not instantiated directly. Unlike the client proxy, the server proxy accesses Remote Server resources and is suitable for storing important data for a long time. Ext. data. proxy. the main configuration items of server are as follows:

Table 7-1 main configuration items of Ext. Data. Proxy. Server

Configuration item

Parameter type Description

API

Object

The default URL for configuring the CRUD operation is

API: {read: undefined,

Create: undefined,

Update: undefined,

Destroy: Undefined

}

If not specified, crud will directly request the original URL

Cachestring

String

Set the parameter name used to damage the random parameters cached by the browser. The default value is _ DC

Directionparam

String

Set the target parameter for sorting. This parameter takes effect only when simplesortmode is set to true. The default value is dir.

Extraparams

Object

Set the extension parameters included in each request. If the parameter names in individual requests conflict with the parameter names, the parameters in extraparams will be overwritten.

Filterparam

String

Set the parameter name of the filter. The default value is filter. If you do not want to pass the filter parameter to the background, set this configuration item to undefined.

Groupparam

String

Set the parameter name of the default group. The default value is group. If you do not want to pass the group parameter to the background, set this configuration item to undefined.

Limitparam

String

Set the page size parameter. The default value is limit. If you do not want to pass the parameter to the background, set this configuration item to undefined.

Nocache

Boolean

Sets whether to prevent browser caching. The default value is true and does not cache. the random parameters configured through cachestring will be appended to the requested URL.

Pageparam

String

Set the start page parameter name to "page" by default. If you do not want to pass it to the background, set this configuration item to "undefined ".

Reader

Object/string/EXT. Data. Reader. Reader

Set the data reader to be used to parse the desired data reader on the server. It can be a reader instance, and the configuration object or valid reader types such as JSON and XML

Simplesortmode

Boolean

Set whether to enable the simple sorting mode. If enabled, only one sorting attribute and one sorting method (ASC or DESC) will be passed to the server when remote sorting is initiated, dirparam and sortparam are used to pass the two parameters respectively.

Sortparam

String

Set the sorting parameter name. The default value is sort. If you do not want to pass the parameter to the background, set this configuration item to undefined.

Startparam

String

Set the start page parameter name. The default value is page. If you do not want to pass the parameter to the background, set this configuration item to undefined.

Timeout

Number

Set the requested supermarket time. The default value is 30 seconds.

URL

String

Set the request server URL

Writer

Object/string/EXT. Data. Writer. Writer Set the writer used to encode the client point request data. It can be a writer instance, and the configuration object or valid reader types such as JSON and XML

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.