PDA

View Full Version : TypeError: Object [object Object] has no method 'getItemId'



SkunkP
23 Feb 2013, 7:50 AM
Hello, I am quite new to ExtJS and actually trying to modify/adapt the MVC webdesktop by Andreas https://github.com/derAndreas/Webdesktop

I want to follow a hierarchy like this


Viewport.js
---Desktop.js
------Topbar.js
----------...
------Bottombar.js
----------...
---Other.js


I am stuck on this getItemId error since several hours so I am looking for help 8-|
Here are some code examples

app.js


Ext.Loader.setConfig({
enabled: true,
paths: 'Ext.ux': 'path/to/ext4/examples/ux'
}
});

Ext.application({
name: 'MyApp',
appFolder: 'app',
autoCreateViewport: true,

controllers: [
'MyApp.controller.desktop.Desktop'
],

views: [
'MyApp.view.Viewport'
]
});


view.Viewport.js


Ext.define('MyApp.view.Viewport', {
extend: 'Ext.container.Viewport',
requires: [
'MyApp.view.desktop.Desktop'
],

initComponent: function() {
var me = this;

Ext.apply(me, {
layout: 'fit',
items: {
xtype: 'myappdesktop'
}
});
me.callParent();
}
});


view.desktop.Desktop.js


Ext.define('MyApp.view.desktop.Desktop', {
extend: 'Ext.panel.Panel',
alias: 'widget.myappdesktop',

initComponent: function() {

/*Various items using xtype + alias */
}
});


The controller is actually only there to have the views array [ 'MyApp.view.desktop.Desktop' ] to see if it does the trick, it does not...
For now I only have several console.log in the views to check if things are working as I want.

I think that the "TypeError: Object [object Object] has no method 'getItemId'" is linked to the Viewport.js when I try to use items : {xtype: 'alias'}

Maybe the way I am working is completely wrong, any helps or inputs are welcome !

Many thanks

EPV
24 Feb 2013, 1:00 AM
1. Have you tried commenting out this in the viewport?

items: {
xtype: 'myappdesktop'
}
2. Are there any difference if you use this instead of the xtype?

Ext.create('MyApp.view.desktop.Desktop')
3. How does the controller looks like?
4. Is the app generated by sencha command?

SkunkP
24 Feb 2013, 4:51 AM
Hello and thank you.

1- Commenting out the item in the viewport makes the error disapear.

2- Using Ext.create works, the Desktop.js is loaded and if I put a console.log in it the output is shown in the console.

3- The controller looks like this


Ext.define('MyApp.controller.desktop.Desktop', {
extend: 'Ext.app.Controller',

views: [
'desktop.Desktop'
]
});


Ext.onReady(function() {
console.log('Desktop-controller loaded');
});



4- And no, the app is written in Netbeans

EPV
24 Feb 2013, 6:04 AM
When writing the same code as you posted I can't get reproduce your error. Are the code in your post exactly the same as the code you're running?

note: Because of you're "require" in the viewport you don't need the controller to load your desktop view.
note: your Ext.loader code in app.js looks strange ...
note: you have autoCreateViewport set to true so you don't need do define that in the views array.


/ E

SkunkP
24 Feb 2013, 6:57 AM
Yes they are exactly the same but the app is named Coala instead of MyApp.

I removed the desktop view in the controller, removed the viewport in the view array and went back to using


initComponent: function() {
var me = this;

Ext.apply(me, {
layout: 'fit',
items: {
xtype: 'myappdesktop'
}
});
me.callParent();
}

instead of Ext.create in the viewport, the error is back :-?
I may use a different approach (more or less what is explained in the MVC on the API docs) and use Ext.create if needed so that I can continue working on this project.

But still I don't understand why I'm not able to call an alias xtype in that way.
I will mark the topic as answered because Ext.create does the workaround but guys feel free to continue investigating.

Thank you EPV