我的应用程序有2个控制器,当start显示一个带有treepanel的简单html时。
每个网格都有(视图,模型,控制器和存储)。当我点击treepanel节点时,我调用了视图,但如果此视图的控制器已在application.js内声明,则此操作正常,如果没有声明我收到错误。
当我点击treepanel节点时,我创建了一个带有网格的tabpanel。 (动态)
错误。 未捕获的错误:[Ext.createByAlias]无法创建无法识别的别名实例:widget.importacaolist
答案 0 :(得分:0)
Ext.define('AwseomeFrontend.view.MyCustomTabPanel',{
extend : 'Ext.tab.Panel',
alias : 'widget.mycustomtabpanel', //make sure you are using widget.something this config is not required but allow you to use Ext.widget instead of Ext.create
});
确保您有这样的配置:
views : [
'MyCustomTabPanel' // this loads the class so you can create instances
]
然后,您可以使用以下命令在控制器中实例化视图:
Ext.create('AwseomeFrontend.view.MyCustomTabPanel') or Ext.widget('mycustomtabpanel')
查找拼写错误
答案 1 :(得分:0)
的application.js
Ext.define('ImpPdf.Application', {
name: 'ImpPdf',
extend: 'Ext.app.Application',
//create a getter of view getImportacaoListView
views: [
'Main',
'TabSobre',
'TabHome',
'TabImportacao',
'TabTransferencia',
'NavegacaoTree',
'importacao.Edit',
'importacao.List'
/*'ClienteList',
'AnuncioList'*/
],
//create a getter of controller getImportacaoController
controllers: [
'Main',
'Navegacao'
//'Importacao'
//'Cliente',
//'Anuncio'
],
//create a getter of store getImportacaoStore
stores: [
'Navegacao'
//'Importacao'
//'Cliente',
//'Anuncio'
]
});
主控制器
Ext.define('ImpPdf.controller.Navegacao', {
extend: 'Ext.app.Controller',
models: ['Navegacao'],
stores: ['Navegacao'],
views: ['NavegacaoTree'],
refs: [{
ref: 'navegacaoTree',
selector: 'navegacaotree'
}],
init: function() {
this.control({
'navegacaotree': {
itemclick: this.onNodeSelect,
afterrender: this.onAfterRender
}
});
},
onNodeSelect: function (view, record, item, index, e, eOpts ) {
this.getController('Main').addTabPanel(record);
},
onAfterRender: function(treePanel, eOpts) {
var store = treePanel.getStore();
//store.setRootNode({ text:'Root', leaf:false, expended:true });
store.load({
scope : this,
callback: function(records, operation, successful) {
if (successful && records.length > 0) {
treePanel.expandAll();
var selectionModel = treePanel.getSelectionModel();
selectionModel.select(0);
}
}
});
}
});
如何使用网格创建tabpanel。
newTab = mainPanel.add({
xtype: className,
title: title
});