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.
-
Sencha Premium User
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.
-
Sencha User
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...
-
Ext JS Premium Member
Same issue here and the workaround to set the window.closeAction to hide often helps.
-
Ext Support Team
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.
-
Sencha Staff
Thanks for the report! I have opened a bug in our bug tracker.
-
Sencha Premium User
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;
}
-
Sencha Premium Member
Your patch worked for me.

Originally Posted by
cesarzea
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;
}
-
Sencha User
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;
});
-
Sencha Premium User
-
Sencha Premium Member
Thank you aniketjondhale@gmail.com! This code still help us, in ExtJS 7.0...

Originally Posted by
aniketjondhale@gmail.com
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;
});