PDA

View Full Version : extJS 3 to extJS 4 migration "not a constructor" Error



houngj
23 Apr 2015, 8:31 AM
I am trying to migrate my extJS 3 application to extJS 4 however I've run into this error -

"TypeError: Ext.ux.AlarmGrid is not a constructor"

Ext.ux.AlarmGrid is extended from Ext.grid.Panel. Here is the section of code that the error is being thrown at.


function initAlarmGridExtend() {
if (!alarmGridExtend || alarmGridExtend === 'undefined') {
alarmGridExtend = new Ext.ux.AlarmGrid({
region: 'south',
title: 'south'
});
}
return alarmGridExtend;
}

Any guidance would help, thanks in advance!

skirtle
23 Apr 2015, 8:53 AM
It appears AlarmGrid doesn't exist yet.

Try this on the line before you try to create it:


console.log(Ext.ux.AlarmGrid);

As for why... Is the file containing AlarmGrid being loaded?

houngj
23 Apr 2015, 9:17 AM
The file containing AlarmGrid is the same file that contains initAlarmGridExtend(). I apologize for asking obvious questions but is there a reason why AlarmGrid wouldn't be loaded?

skirtle
23 Apr 2015, 9:49 AM
Possibly a requires block in the AlarmGrid definition? Or maybe the class it extends isn't loaded yet? If any dependencies are missing the class definition will be deferred.

If the AlarmGrid code is at the end of the file it might just not have reached it yet. It's difficult to say without knowing the timing of the call to initAlarmGridExtend.

houngj
23 Apr 2015, 10:37 AM
So I don't believe this is a dependency issue because Ext.grid.Panel is AlarmGrids only dependency and it is loaded by the time initAlarmGridExtend is called. However when I drop a break point where Ext.ux.AlarmGrids is declared the code never reaches it. Does this mean this is a timing issue? That doesn't really make sense to me because even if it is a timing issue we should still eventually get to the break point right before declaring AlarmGrid right?

skirtle
23 Apr 2015, 3:24 PM
Not necessarily. An exception will prevent subsequent code being run, so if initAlarmGridExtend is being called synchronously from within that file it won't get any further. Being at the 'root level' in a file doesn't change that.