-
11 Aug 2011 3:18 PM #1
Answered: How to stop stores from autoloading with MVC
Answered: How to stop stores from autoloading with MVC
I have a store defined with autoLoad: false but when using the MVC application approach they seem to autoload during the application initiation. Any ideas on how to stop this?
Here is a code sample chopped down.
Code:Ext.define('V.store.Properties', { extend: 'Ext.data.Store', model: 'V.model.Property', autoLoad: false, pageSize: 999, proxy: { type: 'ajax', url: '...endPoint', reader: { type: 'json', root: 'data', totalProperty: 'totalCount', idProperty: 'id' } } }); Ext.define('V.controller.Properties', { extend: 'Ext.app.Controller', stores: [ 'Properties' ], views: [ 'property.Grid' ], models: [ 'Property' ] }); Ext.define('V.view.property.Grid', { extend: 'Ext.grid.Panel', store: 'Properties' }); var v = Ext.create('Ext.app.Application', { name: 'V', appFolder: 'app', controllers: [ 'Properties' ], launch: function() { // more code here that creates an instance of V.view.property.Grid } });
-
Best Answer Posted by mitchellsimoens
Looking at the source for Ext.app.Application (which is where the stores you specify in a Controller get created), the getStore method doesn't do anything to auto load a Store.
If the Store is actually firing the load method, it would be because the StoreManager is falsely doing it but I personally haven't seen this behavior in my 4.x applications.Code:getStore: function(name) { var store = Ext.StoreManager.get(name); if (!store) { store = Ext.create(this.getModuleClassName(name, 'store'), { storeId: name }); } return store; }
-
11 Aug 2011 3:39 PM #2
Do you use the guaranteeRange method of your store at any point? I had set up a buffered store and used guaranteeRange and that performs a load action in the store. I might be way off.

-
11 Aug 2011 4:03 PM #3
-
12 Aug 2011 3:55 AM #4
How good are you with the debugger? Set a breakpoint in Store#load() or by adding 'debugger' in the JS code.
Then trace back the call stack (the class/method that made the call to Store#load) and see where the method call comes from. That might help you understand what is going on.
-
12 Aug 2011 6:00 AM #5Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
- Answers
- 3113
Looking at the source for Ext.app.Application (which is where the stores you specify in a Controller get created), the getStore method doesn't do anything to auto load a Store.
If the Store is actually firing the load method, it would be because the StoreManager is falsely doing it but I personally haven't seen this behavior in my 4.x applications.Code:getStore: function(name) { var store = Ext.StoreManager.get(name); if (!store) { store = Ext.create(this.getModuleClassName(name, 'store'), { storeId: name }); } return store; }Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
15 Oct 2011 10:17 AM #6Sencha - Services Team
- Join Date
- Mar 2008
- Location
- Redwood City, CA
- Posts
- 145
- Vote Rating
- 7
- Answers
- 10
The getStore method instantiates the store by doing "store = Ext.create(...)". This fires the loading if autoLoad = true.
I've seen this same behavior occurring and what I'm doing is avoiding autoLoad and doing something like this into my views:
This way I have store loaded once my view is instantiated, and not when the store is instantiated at application beginning.Code:initComponent: function() { // ... this.callParent(arguments); this.store.load(); }
Cheers!Bruno Tavares, Solutions Engineer
Sencha, Inc.


Reply With Quote