MVC store usage

Source: Internet
Author: User

Sencha touch has structured the MVC idea and can be reflected in the file naming rules and package structure.

In MVC, the relationship between views and data is usually many-to-one. That is to say, a data set may be displayed in multiple views,

In addition, each view may modify the data, and data consistency needs to be maintained.

Store can be understood as a set of data sets (record). It is similar to a database table and has several important concepts related to store:

Model: each store must specify a model to store data.

Dataset: a record after modeling

Proxy: Generally, the data set in the store needs to be obtained from the local/server through the proxy.

The following example shows how a store is displayed in multiple views.

Take the calendar application as an example,

At this time, the store stores all events in a certain period of time.

Generally, calendar has four views,

List View-displays all events in a certain period of time in the form of a list. All data in the store must be presented.

Month view-events are displayed in the unit of month. You need to filter the events of each day of the specified month,

Week view-events are displayed in weeks. You need to filter events of each day of a specified Week,

Day view-displays the time of each day. You need to filter out the events of the specified day.

How to filter a copy of data based on different conditions?

Ext. Data. Store has such a method: filterby (FN, [Scope]), which can filter out store that meets the criteria.

Eg: eventstore. filterby (function (record ){

If (record> 1) return record;

}, This ),

Someview. setstore (eventstore );

In this case, all data greater than 1 is left in eventstore,In fact, data that does not meet the conditions is not deleted,

Instead, it is hidden. You can use clearfilter () to restore the original eventstore, which achieves reuse.

The original store filters out the store that meets different conditions!

# In the same time period (one filter operation), only one filter condition is valid in store !!

 

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.