EXTJS4 Learning (vii) the store in MVC

Source: Internet
Author: User

Ext.data.Store is the standard middleware used for data exchange and data interaction in ExtJS, whether it is a grid or a ComboBox, through which data reading, type conversion, sorting, paging, and searching are performed.

Ext.define (' User ', {    extend: ' Ext.data.Model ', fields    : [        {name: ' LoginName ', type: ' String '},        {name: ' IP ',  type: ' String '}    ]});

Store can read data from the local array, can also read data remotely from the server, of course, can also be read by the server Proxy, which are implemented by proxy, as to what is the distinction, and the implementation of the way will be described in the next section

To better understand the use of the store, we do the following example

var store = ext.create (' Ext.data.Store ', {    model: ' User ',    proxy: {        type: ' Memory ',        data:[{loginname: ' Admin ', IP: ' 192.168.1.2 '},{loginname: ' guest ', IP: ' 192.168.1.5 '}]    },    //autoload:true//configured to indicate that the dataset is automatically loaded}) ;
Some common methods

Load Data store.load ();//Add Data Store.add ({loginname: ' administrator.com ', IP: ' 192.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 domain (field): Store.filter ([              {property: ' LoginName ', Value:/\.com $/},              {filterfn:function (item) {return item.get ("IP") = = ' 192.168.1.5 ';}]); /Find a record of var record = Store.find (' LoginName ', ' guest ');//Get a quick Method for the first record in the store. var record = Store.first ();// Gets the record at the specified index var record = Store.getat (2);//Get the number of records in store var count = store.getcount;//Quick way to get the last record in the store var record = Store.last ();



EXTJS4 Learning (vii) the store in MVC

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.