You forgot to add extend: 'Ext.Toolbar'
to your test.view.mainTool
class. Do not forget, simply defining a class without extending an Ext component does not create a valid Ext View.
Object has no method getId sencha
-
17-06-2023 - |
Вопрос
I'm trying to create a view for toolbar in sencha and import it to my file but it keeps on throwing
Uncaught TypeError: Object [object Object] has no method 'getId'
Tell me what I am doing wrong.
I guess it is not allowed to create a view for toolbar only.
view/mainTool.js
Ext.define('test.view.mainTool',{
requires:['Ext.field.Search'
,'Ext.Toolbar'
],
config:{docked:'top',
ui:'normal',
items:[
{
xtype: 'searchfield',
placeHolder: 'Search...',
left: true,
id:'mainSearch',
width: 200,
},
{
xtype:'button',
ui:'action',
text:'filter',
id:'filter'
},
{xtype:'spacer'},
{
xtype:'button',
ui:'action',
text:'showOnMap',
id:'showOnMap'
},
{
xtype:'button',
ui:'action',
iconCls:'arrow_left',
id:'back'
},
{
xtype:'button',
ui:'action',
iconCls:'home',
id:'home'
}
]
}
});
app.js
Ext.application({
requires: [
'Ext.dataview.List',
'Ext.Panel',
'Ext.Spacer',
'test.view.list',
'test.view.mainTool',
'Ext.List',
'test.model.list1model',
'test.store.list1store'
],
launch : function(){
list1 =Ext.create('test.view.list');
list2 =Ext.create('test.view.list');
list2.setHidden(true);
maintool=Ext.create('test.view.mainTool');
Ext.create('Ext.Container',{
id:'contain',
layout:'hbox',
fullscreen:true,
items:[
maintool,
list1,
{xtype:'spacer'},
list2
]
})
}
});
Решение
Не связан с StackOverflow