ExtJs4 learning Store in MVC

Source: Internet
Author: User

ExtJs4 learning Store in MVC

Ext. data. store is a standard middleware used in extjs for data exchange and data interaction. Both Grid and ComboBox use it to perform data read, type conversion, sorting paging, and search operations.

 

Ext.define('User', {    extend: 'Ext.data.Model',    fields: [        {name: 'loginname', type: 'string'},        {name: 'ip',  type: 'string'}    ]});

Store can read data from the local array or remotely from the server. Of course, it can also be read by the server proxy, which must be implemented by proxy. What are the differences, and the implementation method will be described in the next section

 

To better understand the usage of Store, we will give the following example:

 

Var store = Ext. create ('ext. data. store', {model: 'user', proxy: {type: 'memory ', data: [{loginname: 'admin', ip: '100. 168.1.2 '}, {loginname: 'guest', ip: '2017. 168.1.5 '}]}, // autoLoad: true // This item is configured, indicating that the dataset is automatically loaded });
Common Methods

 

 

// Load the data store. load (); // Add Data store. add ({loginname: 'administrator. com ', ip: '2017. 168.1.8 '}); // read data store. each (function (record) {console.info (record. get ('loginname'); alert (record. get ('loginname') ;}); // filter // store. filter ("loginname ",/\. com $/); filter by a single attribute field: store. filter ([{property: "loginname", value :/\. com $/}, {filterFn: function (item) {return item. get ("ip") = '20180101. 168.1.5 ';}}]); // find a record var record = store. find ('loginname', 'Guest '); // a shortcut to obtain the first record in the store. var record = store. first (); // obtain the record var record = store at the specified index. getAt (2); // obtain the number of records in the store var count = store. getCount; // The shortcut for obtaining the last record in the store. var record = store. last ();



 

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.