Results 1 to 3 of 3

Thread: Reusing Window with ViewModel and Stores results in me.getSuccess is not a function

  1. #1
    Sencha User
    Join Date
    May 2012
    Posts
    53
    Answers
    3

    Default Reusing Window with ViewModel and Stores results in me.getSuccess is not a function

    Hi,

    I have created a window, this window has it's own viewmodel with some stores defined.
    The first time everything is working great, but after closing this window and opening it again results in 'me.getSuccess is not a function' ...

    I have overridden the store applyProxy function because all my CRUD urls are defined in the proxy of my model. To mixin some extraParams in the store definition it is not enough just using the model proxy, I have to create a new instance with the same config and append the extraParams.

    BUT commenting my applyProxy function solves the me.getSuccess error.
    So something must be wrong here.

    Code:
    Ext.define('xx.store.BaseStore', {    extend : 'Ext.data.Store',
    
    
        listeners : {
            load : function(store) {
                console.log(store);
            }
        },
    
    
        applyProxy : function(proxy) {
            var model = this.getModel();
    
    
            if (proxy !== null) {
                if (proxy) {
                    if (proxy.isProxy) {
                        proxy.setModel(model);
                    } else {
                        if (Ext.isString(proxy)) {
                            proxy = {
                                type : proxy,
                                model : model
                            };
                        } else if (!proxy.model) {
                            proxy = Ext.apply({
                                model : model
                            }, proxy);
                        }
    
    
                        proxy = Ext.createByAlias('proxy.' + proxy.type, proxy);
                        proxy.autoCreated = true;
                    }
                } else if (model) {
                    
                    modelProxy = model.getProxy();
                    
                    proxy = Ext.createByAlias('proxy.' + modelProxy.type, modelProxy.getConfig());
                    proxy.extraParams = Ext.apply({}, modelProxy.extraParams, this.extraParams);
                    proxy.autoCreated = true;
                    
                }
    
    
                if (!proxy) {
                    proxy = Ext.createByAlias('proxy.memory');
                    proxy.autoCreated = true;
                }
            }
    
    
            return proxy;
        }
    
    
    });

  2. #2
    Sencha User
    Join Date
    Dec 2016
    Posts
    1

    Default

    I am also facing this same issue. Have you been able to find a solution or workaround for this? please share if you have

  3. #3
    Sencha User
    Join Date
    May 2012
    Posts
    53
    Answers
    3

    Default

    Yes it is working for me.

    The problem is 'proxy.autoCreated = true;'
    Remove that line ant it should work

    Code:
    Ext.define('xxx.store.BaseStore', {    extend : 'Ext.data.Store',
    
    
        applyProxy : function(proxy) {
    
    
            var model = this.getModel();
    
    
            if (proxy !== null) {
    
    
                if (proxy) {
    
    
                    if (proxy.isProxy) {
                        proxy.setModel(model);
                    } else {
                        if (Ext.isString(proxy)) {
                            proxy = {
                                type : proxy,
                                model : model
                            };
                        } else if (!proxy.model) {
                            proxy = Ext.apply({
                                model : model
                            }, proxy);
                        }
    
    
                        proxy = Ext.createByAlias('proxy.' + proxy.type, proxy);
                        proxy.autoCreated = true;
                    }
    
    
                } else if (model) {
    
    
                    modelProxy = model.getProxy();
    
    
                    proxy = Ext.createByAlias('proxy.' + modelProxy.type, modelProxy.getConfig());
                    proxy.extraParams = Ext.apply({}, modelProxy.extraParams, this.extraParams);
    
    
                }
    
    
                if (!proxy) {
                    proxy = Ext.createByAlias('proxy.memory');
                    proxy.autoCreated = true;
                }
    
    
            }
    
    
            return proxy;
    
    
        }
    
    
    });

Similar Threads

  1. ViewModel stores help
    By Txoov in forum Ext 5: Q&A
    Replies: 23
    Last Post: 25 Mar 2015, 9:41 PM
  2. Reusing Stores
    By asantos.lnascimento in forum Sencha Architect 3.x: Q&A
    Replies: 1
    Last Post: 23 Dec 2014, 8:34 AM
  3. Replies: 1
    Last Post: 30 Jul 2014, 2:53 PM
  4. Reusing Stores Throughout Application
    By Peter Tierney in forum Sencha Architect 2.x: Help & Discussions
    Replies: 3
    Last Post: 10 Jan 2013, 11:40 AM
  5. Reusing data stores with fresh parameters
    By jakeext in forum Ext 2.x: Help & Discussion
    Replies: 5
    Last Post: 4 Jun 2009, 2:04 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •