Michel
Michel

Reputation: 571

ExtJS5 ViewModel using global declared store

According to this post and this one, there are 2 ways of using an external declared store into a viewModel. In the first example type is used and in the second one source is used.
My Problem is that type and source are not documented as config part.

Is there any other way to use external declared stores in a viewModel? Which one should be used? Why? Where is the related documentation to find?
(I use extjs5.1.1 GPL)

Upvotes: 2

Views: 1516

Answers (1)

Robert Watkins
Robert Watkins

Reputation: 2206

type should be used if you want to create a new instance of a Store, per view model.

source should be used if you have a store instance (either passed in, or available globally through the store manager) that you want to use as the backing store. As a chained store, data changes will be passed through, but you can sort or filter it without impacting the source store (which is handy for displays).

You can also create or assign stores directly. Assigning (e.g assigning a store passed into the view) is fine, but creation is discouraged - if you use Ext.create to create a new store when defining a ViewModel, that store will be on the prototype, and shared amongst all the ViewModel instances. In general, you'd be better off using the StoreManger than doing that.

Upvotes: 2

Related Questions