Click to search on your search term.
Subscribe to Fig Leaf Tutorials

Need help with a project? Contact us at
From code reviews to project "jumpstarts" and full life-cycle development, we've got you covered!
Check out our case studies!
Follow us on Twitter!
Click here to join our Facebook group!

Ready to upgrade your skills? Try these instructor-led classes in Washington, DC:

Defining a Data Store

Page of 168

Stores represent a local container of model instances. Most of your interaction with Models with happen through a Store.

Stores operate in a manner similar to arrays. The creation, deleting, and updating of models are handled by the Store's methods. A Store also provides methods for filtering, sorting, and grouping its records.

Each store in your application will have a corresponding model. As a best practice Store class names are the plural of its corresponding model, thereby indicating that it contains multiple model instances. Note that in the code snippet below, the class name for the store is the plural of its associated model name.

Ext.define( '', {
 extend: '',
 requires: ['FriendsWithBeer.model.User'],
 config: {
   autoLoad: true,
   model: 'FriendsWithBeer.model.User',
   storeId: 'Friends',
   autoSync: true

Configuring a Store

You will typically configure the following properties:

Property Description
autoLoad Boolean. When set to true the store uses its proxy, or the proxy of its model if not defined, to populate on instantiation.
storeId String. A unique identifier used to access this store globally using the Ext.getStore method. The storeId is also used to associate this store with views.
model String/Object. A reference to the model class for this store.
autoSync Boolean. When true, CRUD operations are enabled allowing the store to auto commit any models created, deleted, or updated. This will require additional configuration for Ajax proxies. JSON-P is not supported.

Invoking Store Methods

Commonly used methods for accessing data from a Store include the following:

Method Description
add() Add a model instance to a Store.
clearFilter() Removes the filter and restores any filtered records.
filter() Filters the records by a specified criteria.
getAt(Number) Get the model record at the specified position in the store.
getCount() Returns the number of records in the store. Filtered records are not included in the count.
sort(sorters) Sorts the records in the Store by one or more properties.
Page of 168
comments powered by Disqus