如何在ExtJS 4中的窗口中放置表单面板

如何在ExtJS 4中的窗口中放置表单面板,extjs,Extjs,我试图在一个窗口中放置一个表单,我正在处理web桌面的示例,我在“开始”菜单上添加了一个新条目,它应该调用一个窗口,在该窗口中必须有一个表单,但它似乎无法在窗口中显示该表单。我正在粘贴表单的代码和创建窗口的模块 Ext.define('MyDesktop.HelloWorldWindowModule', { extend: 'Ext.ux.desktop.Module', init : function(){ this.launcher = {

我试图在一个窗口中放置一个表单,我正在处理web桌面的示例,我在“开始”菜单上添加了一个新条目,它应该调用一个窗口,在该窗口中必须有一个表单,但它似乎无法在窗口中显示该表单。我正在粘贴表单的代码和创建窗口的模块

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;
    }
});
现在问题已经解决了,所以我将把解决方案放在代码中

专家组代码

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”选项时,它就会显示出来。

现在魔法开始工作了;)

createWindow
中添加
布局:'fit'
并将项更改为
项:[hello]

尝试
项:[hello]
--项应该是复数,hello不是此属性谢谢回答。实际上,这是我遇到的问题之一,奇怪的是,构造函数给我带来了麻烦。同样感谢你的回答,布局属性对我很有用!