Go Store in the ExtJS

Source: Internet
Author: User
Tags autoload

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
  1. Ext.onready (function () {
  2. Defines the model of a person
  3. Ext.define ("person", {
  4. Extend: "Ext.data.Model",
  5. fields:[
  6. {name: ' Name '},
  7. {Name: "Age"}
  8. //       ]
  9. //     });
  10. A store dataset was created
  11. var s=new Ext.data.Store ({
  12. //store can define fields by itself, omitting model
  13. fields:[
  14. {name:' name '},
  15. {Name:"Age"}
  16. ],
  17. //If the agent is used, you can omit the store's Data property
  18. proxy:{
  19. Type:"Ajax",
  20. URL:"person.jsp"
  21. }
  22. data:[
  23. {Name: "hanhan313", age:23},
  24. {Name: "hanhan313", age:22}
  25. //         ],
  26. //model: "Person"
  27. //autoload:true
  28. });
  29. S.each (function (model) {
  30. Ext.Msg.alert ("title", Model.get ("name"));
  31. Alert (Model.get ("name"));
  32. //     });
  33. //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
  34. S.load (function (records,operation, success) {
  35. Ext.Array.each (Records,function (model) {
  36. Alert (Model.get ("name"));
  37. });
  38. });
  39. });

person.jsp page:

Data in JSON format:

<%

Response.getwriter (). Write ("[{name: ' hanhan313 ', age:26},{name: ' Hahaha ', age:34}]");

%>

Go Store in the ExtJS

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.