Store is a collection cache of data object model that can provide data (Gridpanel,combobox) for ExtJS visualization
Class structure
Ext.data.AbstractStore
Ext.data.Store No special circumstances, this class can be full of daily development
Ext.data.ArrayStore
Ext.data.DirectStore
Ext.data.ArrayStore built-in helper classes
Ext.data.JsonStroe built-in helper classes
Ext.data.TreeStore
Ext.data.Store use
Parameters
AutoLoad (boolean/object): Automatically load data, automatically call load
Data (Array): An array of built-in objects that are initialized to be loaded in
Model: Data collection-related models
Field: A collection of fields that the program automatically generates for the model
Method
Each (Function f, [Object scope]): Model in void variable data
code example:
[JavaScript]View Plaincopy
- Ext.onready (function () {
- Defines the model of a person
- Ext.define ("person", {
- Extend: "Ext.data.Model",
- fields:[
- {name: ' Name '},
- {Name: "Age"}
- // ]
- // });
- A store dataset was created
- var s=new Ext.data.Store ({
- //store can define fields by itself, omitting model
- fields:[
- {name:' name '},
- {Name:"Age"}
- ],
- //If the agent is used, you can omit the store's Data property
- proxy:{
- Type:"Ajax",
- URL:"person.jsp"
- }
- data:[
- {Name: "hanhan313", age:23},
- {Name: "hanhan313", age:22}
- // ],
- //model: "Person"
- //autoload:true
- });
- S.each (function (model) {
- Ext.Msg.alert ("title", Model.get ("name"));
- Alert (Model.get ("name"));
- // });
- //In addition to automatic loading, can also be manually loaded, if the use of agents should be used manually loaded, because the use of automatic loading, the traversal of the use of data is still loaded asynchronously, did not get to
- S.load (function (records,operation, success) {
- Ext.Array.each (Records,function (model) {
- Alert (Model.get ("name"));
- });
- });
- });
person.jsp page:
Data in JSON format:
<%
Response.getwriter (). Write ("[{name: ' hanhan313 ', age:26},{name: ' Hahaha ', age:34}]");
%>
Go Store in the ExtJS