1. #1
    Sencha User
    Join Date
    Jan 2008
    Posts
    45
    Vote Rating
    0
    netslayer is on a distinguished road

      0  

    Default 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
            }
    });

  2. 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.

    Code:
        getStore: function(name) {
            var store = Ext.StoreManager.get(name);
    
            if (!store) {
                store = Ext.create(this.getModuleClassName(name, 'store'), {
                    storeId: name
                });
            }
    
            return 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.

  3. #2
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    2,320
    Vote Rating
    64
    Answers
    170
    slemmon is just really nice slemmon is just really nice slemmon is just really nice slemmon is just really nice slemmon is just really nice

      0  

    Default


    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.

  4. #3
    Sencha User
    Join Date
    Jan 2008
    Posts
    45
    Vote Rating
    0
    netslayer is on a distinguished road

      0  

    Default


    nope, not using that.

  5. #4
    Sencha User mberrie's Avatar
    Join Date
    Feb 2011
    Location
    Bangkok, Thailand
    Posts
    506
    Vote Rating
    13
    Answers
    25
    mberrie will become famous soon enough mberrie will become famous soon enough

      0  

    Default


    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.

  6. #5
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,714
    Vote Rating
    438
    Answers
    3113
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    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.

    Code:
        getStore: function(name) {
            var store = Ext.StoreManager.get(name);
    
            if (!store) {
                store = Ext.create(this.getModuleClassName(name, 'store'), {
                    storeId: name
                });
            }
    
            return 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.
    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.

  7. #6
    Sencha - Services Team bt_bruno's Avatar
    Join Date
    Mar 2008
    Location
    Redwood City, CA
    Posts
    145
    Vote Rating
    7
    Answers
    10
    bt_bruno is on a distinguished road

      0  

    Default


    Quote Originally Posted by mitchellsimoens View Post
    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.
    ...
    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:

    Code:
    initComponent: function() {
    	// ...
    	this.callParent(arguments);
    	this.store.load();
    }
    This way I have store loaded once my view is instantiated, and not when the store is instantiated at application beginning.

    Cheers!
    Bruno Tavares, Solutions Engineer
    Sencha, Inc.