我正在使用ExtJS4.1.1为网页创建一个GUI。我已经尝试创建一个组件(下面的“GeneSearchComponent”),我可以在一个更复杂的布局中使用它。但出于某种原因,我无法将'GeneSearchComponent‘的实例插入到hpanel中。在扩展预定义的'Ext.panel.Panel‘类(以及创建自己的“小部件”)时,我遗漏了什么?
如果我删除对"Ext.create('gene-search-component', ...“的调用,一切都会正常工作;如果我把它放回去,一切都会中断。我想知道为什么。
(我没有包括“基因-组合框”的定义。我很确信这不是我问题的根源。)
耽误您时间,实在对不起!
塔玛斯
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,
});
}
});发布于 2012-10-03 12:16:10
问题是,在配置gene-search-component别名时,您还没有给它赋予widget命名空间。
alias: 'widget.gene-search-component'此外,为了响应OP上的注释,您正在进行大量不必要的输入,以您的方式创建组件。您应该使用xtype字段,而不是到处使用Ext.Create。我已经修改了您的代码,以向您展示它可以简单得多。
http://jsfiddle.net/hzXx8/
https://stackoverflow.com/questions/12707347
复制相似问题