Dojox.grid.data Use Guide

Source: Internet
Author: User
dojo0.9 's store core content.
Recently studied some, also translated some, posted out and share with you. More content from Dojo can be viewed on the www.dojocn.cn.

The content is original, reprint please specify:
What is Dojo.data?

<?xml:namespace prefix = o ns = "Urn:schemas-microsoft-com:office:office"/>

Dojo.data is a unified data access layer, it has no database-driven concept, just a unified data format.

All data is represented as a child item or attribute of the item, so that data can be accessed in a uniform manner.

To get it directly, Dojo.data provides a basic jsonitemstore to read JSON data in a particular format.

DojoX this project (or module) provides more stores (for example: Xmlstore, Csvstore, Omplstore), which can be used to resolve data provided by the server in the corresponding formats.

In addition, Dojo.data is an API that other users can rewrite, a concept similar to a Java interface, so you can write a subset of the Dojo.data in a custom data format.

When you customize your own specific format and follow the Dojo.data specification, widgets can know your datastore directly, and other programs can read your data without knowing your particular format.

The ultimate goal of Dojo.data is to provide an Easy-to-use API set, like interfaces. Make Datastore be customized or rewritten in a uniform format.

The store, written as a standard interface, can be used by a wide variety of applications, widgets, and so on.

Essentially, the API hides the data in a particular format, which is in json,xml,csv or other data formats, and provides a consistent way to read the item's attributes, and the user can customize the optimized method to read the data based on actual usage. (This is not a good translation)

You can understand that Dojo.data is a layer on the dojo.xhrget (which encapsulates the XMLHTTP sending requests to the server), and they all do not have to refresh the page's asynchronous operation. But Xhrget will be able to read any MIME-type data and return it all at once, It then relies on the store to translate the data into the required format, thus forming a general reading model.

In summary: Dojo.data provides a uniform way to read data, and its purpose is to provide a standard by which you develop methods of reading data.

Dojo.data are very closely related to page components, such as tree and Combox, using store as the data source. So learning this is helpful for flexible use of widgets.

=============================================================================================================== ========== Dojo.data Terminology

Dojo.data terminology similar to relational database terminology, the following compares and contrasts the terms of dojo.data terminology and relational databases:

Dojo:datastore

Db:cursor

Description: JS object reads from data source through Dojo.data APIs and makes data item available

Dojo Terminology: Data sorece

DB Terminology: Table

Description: This is where the raw data is saved, for example: a Csvstore data source may be a. csv format file, typically, data source is a file or a database server, or a webservice or other

Dojo Terminology: Item

DB terminology: Row

Description: The data item has many properties, all of which have a value

Dojo Terminology: Attribute

DB Terminology: Column

Description: The field or attribute of an item.

Dojo Terminology: Value

DB Terminology:-

Description: The contents of the property

Dojo Terminology: Reference

DB Terminology:-

Description: One item points to the value of another item

Dojo Terminology: Identity

DB Terminology: Primary key

Description: Primary Key

Dojo Terminology: Query

DB terminology: Where words

Description: Conditions for reading data. Note: It is highly recommended that all store use attribute-Name/value structures to connect stores as a query format.

Internal data representation: A proprietary structure datastore used to cache data to clients, such as XML DOM nodes, anonymous JSON objects, or arrays

Dojo Terminology: Request

DB Terminology: SQL Select

Description: A parameter used to filter item, including query, filter attributes, case limitations, and callback functions

=============================================================================================================== ==============

www.dojocn.cn reprint please indicate Dojo.data design and programming interface

Among the direct learning Dojo.data APIs, the basic concepts before studying APIs must be explored, because some design decisions are chosen, but there is no explanation for why they are chosen, which may make the design look strange. So, before you look at the API details, read the concepts completely:

Concept 1: Data access is partitioned into separate apis,store can have the choice to implement these APIs

Data access is broken into separate APIs because not all services and data postbacks require all access or functions. So not all datastore can implement functions such as read,write,identify,notifications (note that the functions here are JS's function, which can be imagined as a Java interface).

To be able to simply know what the store offers, each store must provide the getfeatures () function, which reports which APIs are used in the store.

The following is the basic APIs definition:

Dojo.data.api.Read: able to read items and attributes from a dataitems. And can query, sort, filter data.

Dojo.data.api.Write: Able to generate, delete, update dataitems and attribute. Not all services are allowed to modify data items. In fact, most public services, such as flikr,delicious and GoogleMaps, provide only read services.

Dojo.data.api.Identity: The ability to find a data item by uniquely identifying the location, not all data services have a unique identifier.

Dojo.data.api.Notification: The ability to notify listeners of data modification events that occur on the store. The underlying functionality is the events that generate, delete, and update one data item. It is useful to notify the backend service of events such as updating data regularly.

Some of the future features:

The following features are some of the additional features that the Dojo development community will define, which are not entirely clear and are still under development. Therefore, they are not provided in the current version of the development package. Note that the list below may change at any time.

Dojo.data.api.Schema

Dojo.data.api.Attribution

Dojo.data.api.Versioning

Dojo.data.api.Derivation

www.dojocn.cn Reprint Please specify

Concept two: The properties of data items and data items are often accessed, modified, created, and deleted by the store's functions, and are never accessed directly.

The idea is to prevent Dojo.data from appearing chaotic at first, and the following example shows the concept:

---------------------------------------------------------------------------------

var store = new Some.data.Store ();

var items;

.......

Assuming that the items have been Store.fetch (), the data has become an array

To enumerate the values of this array, you have to do this:

for (Var i=0;i<items.length;i++) {

var item=items[i];

Console.log ("for attribute &apos;foo&apos; Value was:["+store.getvalue (item," foo ") +"] ";

}

----------------------------------------------------------------------------------

Why not do it like the following?

var value=item["Foo"];

var Value=item.foo;

var value=item.getvalue ("foo");

Why this is what dojo.data must ask for. Here's why:

1, access efficiency. Through the store's function access, the store can hide the item's internal structure, regardless of the special form of the data format, the item can maintain a format. For example:

The item may be an XML element, in which case the store will use the DOM API to access the data when Store.getvalue () is invoked; in another case, if item is a JavaScript structure, The store will then access the data through JavaScript's access symbols. From the end-user's point of view, the visit is the same: Store.getvalue (item, "attribute"), This provides a unified sense of access to diverse types of data. By reducing the number of times the item is loaded, it also increases the efficiency of accessing the item because you don't have to convert the format every time.

2, the store can use very concise internal structure

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.