Results 1 to 9 of 9

Thread: Cannot read property 'viewModel' of null

    You found a bug! We've classified it as EXTJS-27586 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha Premium User
    Join Date
    Dec 2010
    Posts
    217
    Vote Rating
    11
      2  

    Exclamation Cannot read property 'viewModel' of null

    Code:
    getConfig: function()
        ......
        ret = me.hasOwnProperty(propName) ? me[propName] : me.config[name];
    The above snippet is from ext-all-rtl-debug.js file.

    It looks like the getConfig function assumes that "me" object is always going to have config and so tries to get me.config[name] in the above statement without checking if me.config even exists. In some cases in my code, it throws an error saying

    Cannot read property 'viewModel' of null

    as me.config object is null. Is this a bug with Ext6? Adding a check if the me.config exists fixes my issue.

    I am using Ext 6.5.3 Classic.

  2. #2
    Sencha User
    Join Date
    Jul 2017
    Posts
    1
    Vote Rating
    0
      0  

    Default

    I am using Ext 6.5.3 Classic as well and currently dealing with this error with a window holding a pivotgrid, it triggers after using the pivotcellediting and then later closing the window, I end up with "Cannot read property 'viewModel' of null" at the same code source.

    While your solution works I'm not a huge fan of editing the ext-all code.

    I have been dealing with this for a few days on and off and unfortunately my only work around so far has been to use
    Code:
    closeAction: 'hide'
    on the window, everything works fine in my case afterwards however this doesn't actually solve anything real...

  3. #3
    Ext JS Premium Member mcouillard's Avatar
    Join Date
    Jun 2008
    Location
    Bucks County, PA
    Posts
    115
    Vote Rating
    13
      0  

    Default

    Same issue here and the workaround to set the window.closeAction to hide often helps.

  4. #4
    Ext Support Team
    Join Date
    Jan 2018
    Posts
    462
    Vote Rating
    -328
      -4  

    Default

    Hello,

    Hope you are doing well, As stated, this happens only when component is not available and we are trying to access its view model. Hiding the window is the solution in this case.

    Regards,
    Kumar
    Sencha Support.

  5. #5
    Sencha Staff
    Join Date
    Sep 2017
    Posts
    124
    Vote Rating
    -108
      0  

    Default

    Thanks for the report! I have opened a bug in our bug tracker.

  6. #6
    Sencha Premium User
    Join Date
    Nov 2007
    Location
    Madrid, Spain
    Posts
    23
    Vote Rating
    4
      1  

    Default

    Sorry but it's not the solution, it's a very bad patch that force us to be unable to liberate resources and memory from 2010 to now (9 years).

    The problem perhaps could be solved changing the line 13793 in ext-all-debug.js (6.7.0.210). That solve the problem in my case for now:

    Old line:

    Code:
    ret = me.hasOwnProperty(propName) ? me[propName] : me.config[name];
    New line:
    Code:
    ret = me.hasOwnProperty(propName) ? me[propName] : (me.config == null ? null : me.config[name]);
    The final getConfig function then:
    Code:
    getConfig: function(name, peek, ifInitialized) {
        var me = this,
            ret, cfg, propName;
        if (name) {
            cfg = me.self.$config.configs[name];
            if (cfg) {
                propName = me.$configPrefixed ? cfg.names.internal : name;
                // They only want the fully initialized value, not the initial config,
                //  but only if it's already present on this instance.
                // They don't want to trigger the initGetter.
                // This form is used by Bindable#updatePublishes to initially publish
                // the properties it's being asked make publishable.
                if (ifInitialized) {
                    ret = me.hasOwnProperty(propName) ? me[propName] : null;
                } else if (peek) {
                    // Attempt to return the instantiated property on this instance first.
                    // Only return the config object if it has not yet been pulled through
                    // the applier into the instance.
                    ret = me.hasOwnProperty(propName) ? me[propName] : (me.config == null ? null : me.config[name]);
                } else {
                    ret = me[cfg.names.get]();
                }
            } else {
                ret = me[name];
            }
        } else {
            ret = me.getCurrentConfig();
        }
        return ret;
    }
    -------------------------------------
    SQL Server expert consultant.
    ExtJS developer from ExtJS 1.0 version to now.
    Java developer.


    Working as freelance and in my own company from 1.999
    https://www.linkedin.com/in/cesarzea/
    www.jaunesistemas.com

  7. #7
    Sencha Premium Member danielbragaalmeida's Avatar
    Join Date
    Jun 2015
    Location
    Mogi das Cruzes, Brazil
    Posts
    3
    Vote Rating
    4
      0  

    Default

    Your patch worked for me.

    Quote Originally Posted by cesarzea View Post
    Sorry but it's not the solution, it's a very bad patch that force us to be unable to liberate resources and memory from 2010 to now (9 years).

    The problem perhaps could be solved changing the line 13793 in ext-all-debug.js (6.7.0.210). That solve the problem in my case for now:

    Old line:

    Code:
    ret = me.hasOwnProperty(propName) ? me[propName] : me.config[name];
    New line:
    Code:
    ret = me.hasOwnProperty(propName) ? me[propName] : (me.config == null ? null : me.config[name]);
    The final getConfig function then:
    Code:
    getConfig: function(name, peek, ifInitialized) {
        var me = this,
            ret, cfg, propName;
        if (name) {
            cfg = me.self.$config.configs[name];
            if (cfg) {
                propName = me.$configPrefixed ? cfg.names.internal : name;
                // They only want the fully initialized value, not the initial config,
                //  but only if it's already present on this instance.
                // They don't want to trigger the initGetter.
                // This form is used by Bindable#updatePublishes to initially publish
                // the properties it's being asked make publishable.
                if (ifInitialized) {
                    ret = me.hasOwnProperty(propName) ? me[propName] : null;
                } else if (peek) {
                    // Attempt to return the instantiated property on this instance first.
                    // Only return the config object if it has not yet been pulled through
                    // the applier into the instance.
                    ret = me.hasOwnProperty(propName) ? me[propName] : (me.config == null ? null : me.config[name]);
                } else {
                    ret = me[cfg.names.get]();
                }
            } else {
                ret = me[name];
            }
        } else {
            ret = me.getCurrentConfig();
        }
        return ret;
    }

  8. #8
    Sencha User
    Join Date
    Aug 2018
    Posts
    5
    Vote Rating
    1
      1  

    Default

    Hi danielbragaalmeida

    Can we include this code change as override

    Code:
    Ext.define('Ext.overrides.Base', {
    override: 'Ext.Base',
    getConfig: function(name, peek, ifInitialized) { var me = this,
    ret, cfg, propName;
    if (name) {
    cfg = me.self.$config.configs[name];
    if (cfg) {
    propName = me.$configPrefixed ? cfg.names.internal : name;
    // They only want the fully initialized value, not the initial config,
    // but only if it's already present on this instance.
    // They don't want to trigger the initGetter.
    // This form is used by Bindable#updatePublishes to initially publish
    // the properties it's being asked make publishable.
    if (ifInitialized) {
    ret = me.hasOwnProperty(propName) ? me[propName] : null;
    } else if (peek) {
    // Attempt to return the instantiated property on this instance first.
    // Only return the config object if it has not yet been pulled through
    // the applier into the instance.
    ret = me.hasOwnProperty(propName) ? me[propName] : (me.config == null ? null : me.config[name]);
    } else {
    ret = me[cfg.names.get]();
    }
    } else {
    ret = me[name];
    }
    } else {
    ret = me.getCurrentConfig();
    }
    return ret;
    
    });

  9. #9
    Sencha Premium User
    Join Date
    Nov 2007
    Location
    Madrid, Spain
    Posts
    23
    Vote Rating
    4
      0  
    -------------------------------------
    SQL Server expert consultant.
    ExtJS developer from ExtJS 1.0 version to now.
    Java developer.


    Working as freelance and in my own company from 1.999
    https://www.linkedin.com/in/cesarzea/
    www.jaunesistemas.com

Similar Threads

  1. Replies: 0
    Last Post: 7 Sep 2017, 1:58 AM
  2. cannot read property 'id' of null
    By hyde007 in forum Sencha Touch 2.x: Q&A
    Replies: 4
    Last Post: 11 Jul 2016, 4:52 AM
  3. [FIXED] Cannot read property 'isFocusable' of null or 'focus' of null
    By SebTardif in forum Ext 5: Bugs
    Replies: 3
    Last Post: 20 Mar 2015, 7:27 AM
  4. Replies: 2
    Last Post: 20 Jul 2014, 12:59 AM
  5. Cannot read property 'xxx' of null
    By rgilkes in forum Sencha Touch 1.x: Discussion
    Replies: 6
    Last Post: 12 Oct 2011, 7:45 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
  •