【发布时间】:2014-05-05 20:37:30
【问题描述】:
我试图在窗口中放置一个表单,我正在处理 Web 桌面的示例,我在开始菜单上添加了一个新条目,该条目应该调用一个窗口,并且在该窗口内必须有一个窗体,但似乎无法在窗口内显示窗体。我正在粘贴表单的代码和创建窗口的模块。
现在问题已经解决了,所以我要把解决方案放在代码中。
面板代码
Ext.define('MyDesktop.HelloWorldWindow',{
extend:'Ext.form.Panel',
bodyPadding: 10,
defaultType: 'textfield',
items: [
{
fieldLabel: 'First Name',
name: 'firstName',
anchor:'100%'
},
{
fieldLabel: 'Last Name',
name: 'lastName',
anchor:'100%'
},
{
xtype: 'datefield',
fieldLabel: 'Date of Birth',
name: 'birthDate',
anchor:'100%'
}
]
});
创建窗口的模块代码。
Ext.define('MyDesktop.HelloWorldWindowModule', {
extend: 'Ext.ux.desktop.Module',
init : function(){
this.launcher = {
text: 'Hello World',
iconCls:'bogus',
handler : this.createWindow,
scope: this,
id:'hello-world'
}
},
createWindow : function(src){
var desktop = this.app.getDesktop();
var win = desktop.getWindow('hello-world');
var hello = new MyDesktop.HelloWorldWindow();
if(!win){
win = desktop.createWindow({
id: 'helloWorld',
title:src.text,
width:640,
height:480,
iconCls: 'bogus',
animCollapse:false,
constrainHeader:true,
items: [hello]
});
}
win.show();
return win;
}
});
当我点击菜单中的“Hello World”选项时才显示这个。
现在魔法起作用了 ;)
【问题讨论】:
-
try
items: [hello]-- items 应该是复数,hello 不是 this 的属性 -
感谢您的回答。实际上这是我遇到的问题之一,而且奇怪的是构造函数给了麻烦。
标签: extjs