题
我正在使用Ext JS 4.1.1为网页创建GUI。我尝试创建一个组件(下面的' genesearch component '),我可以以更复杂的布局使用。但由于某种原因,我无法将“ genesearchComponent ”的实例插入到 HPanel 中。在扩展预定义的' ext.panel.panel '类时,我缺少什么(以及创建我自己的“小部件”)?
如果我删除了“Ext.create('gene-search-component', ...
”的调用,一切都可以工作;如果我把它放回了,一切都在休息。我想知道为什么。
(我没有包括'基因组合框'的定义。我很相信这不是我问题的根本原因。)
谢谢你的时间!
tuomas
Ext.define('GeneSearchComponent', {
extend: 'Ext.panel.Panel',
alias: ['gene-search-component'],
constructor: function(cnfg) {
this.callParent(arguments);
this.initConfig(cnfg);
},
config: {
collapsible: true,
frame: true,
title: 'Search',
bodyPadding: '15 15 15 15',
width: 350,
layout: {
type: 'vbox',
align: 'left'
},
items: [
Ext.widget('gene-combobox', {
id: 'comboboxid'
}),
Ext.create('Ext.Button', {
text: 'Search',
handler: function() {
dosomething();
}})]
},
onRender: function() {
this.callParent(arguments);
}
});
Ext.application({
name: 'FW',
launch: function() {
var bd = Ext.getBody();
var div = Ext.get("search_form");
var hpanel = Ext.create('Ext.panel.Panel', {
id: 'horizontal-panel',
title: "HBoxLayout Panel",
layout: {
type: 'hbox',
align: 'middle'
},
items: [
Ext.create('Ext.container.Container', {
id: 'another-panel',
title: "VBoxLayout Panel",
width: 250,
layout: {
type: 'vbox',
align: 'left'
},
items: [{
xtype: 'panel',
width: 250,
title: ' Panel One',
flex: 2
},{
xtype: 'panel',
width: 250,
title: ' Panel Two',
flex: 1
},{
xtype: 'panel',
width: 250,
title: ' Panel Three',
flex: 1
}]}),
Ext.create('gene-search-component', {
id: 'searchPanel',
})],
renderTo: div,
});
}
});
. 解决方案
问题是,在配置其别名时,您尚未给出gene-search-component
命名空间。
alias: 'widget.gene-search-component'
.
还要回应您的op上的评论,您正在进行很多不必要的键入您所在的方式。您应该使用XType字段而不是到处使用Ext.Create。我修改了代码以向您展示它有多少钱。
不隶属于 StackOverflow