javascript - 在 EXT JS 中显示窗口

标签 javascript extjs

var win,
        button = Ext.getCmp('show-btn');

    button.on('click', function(){
            win = Ext.define('MyApp.view.LeftRightWIndow', {
                extend: 'Ext.window.Window',

                height: 368,
                width: 546,
                title: 'My Window',

                initComponent: function() {
                    var me = this;

                    Ext.applyIf(me, {
                        items: [
                            {
                                xtype: 'container',
                                height: 193,
                                width: 515,
                                layout: {
                                    align: 'center',
                                    type: 'hbox'
                                },
                                items: [
                                    {
                                        xtype: 'container',
                                        flex: 1,
                                        margins: '',
                                        height: 135,
                                        padding: '10 10 10 10',
                                        width: 114,
                                        layout: {
                                            type: 'column'
                                        },
                                        items: [
                                            {
                                                xtype: 'textfield',
                                                padding: '0 0 10 0',
                                                width: 233,
                                                fieldLabel: 'Label'
                                            },
                                            {
                                                xtype: 'textfield',
                                                padding: '0 0 10 0',
                                                width: 233,
                                                fieldLabel: 'Label'
                                            }
                                        ]
                                    },
                                    {
                                        xtype: 'container',
                                        flex: 1,
                                        margins: '',
                                        height: 135,
                                        padding: '10 10 10 10',
                                        width: 114,
                                        layout: {
                                            type: 'column'
                                        },
                                        items: [
                                            {
                                                xtype: 'textfield',
                                                padding: '0 0 10 0',
                                                width: 233,
                                                fieldLabel: 'Label'
                                            },
                                            {
                                                xtype: 'textfield',
                                                padding: '0 0 10 0',
                                                width: 233,
                                                fieldLabel: 'Label'
                                            }
                                        ]
                                    }
                                ]
                            }
                        ],
                        dockedItems: [
                            {
                                xtype: 'toolbar',
                                dock: 'top',
                                items: [
                                    {
                                        xtype: 'tbtext',
                                        autoRender: true,
                                        cls: 'save',
                                        height: 26,
                                        padding: '5 5 5 5',
                                        width: 43,
                                        text: 'Save'
                                    },
                                    {
                                        xtype: 'tbseparator'
                                    },
                                    {
                                        xtype: 'tbtext',
                                        autoRender: true,
                                        cls: 'edit',
                                        height: 26,
                                        padding: '5 5 5 5',
                                        width: 43,
                                        text: 'Edit'
                                    }
                                ]
                            }
                        ]
                    });

                    me.callParent(arguments);
                }

            });
  });

如何在按下show-btn时显示窗口?
此代码我使用 Sencha Articheh 创建。有什么想法吗?

最佳答案

使用 Ext.define() 方法定义类,但不创建类的实例。要创建类实例,您必须使用 Ext.create() 方法。

我还建议将类定义移到单击处理程序之外的单独文件中。如果您使用的是 Sencha 架构师创建的标准应用程序结构,请在 View 文件夹中创建具有类定义的文件。

所以在点击处理程序中你将只有:

// create instance of MyApp.view.LeftRightWIndow class
win = Ext.create('MyApp.view.LeftRightWIndow');
// display window
win.show();

关于javascript - 在 EXT JS 中显示窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20441539/

相关文章:

javascript - ExtJS 没有使用我的网格过滤器覆盖

javascript - 如何将 Node.js 变量传递/访问到 html 文件/模板

javascript - Parsleyjs 日期验证不适用于像 Onchange 这样的 Datepicker 事件

css - 有人可以解释为什么 Sencha Toolbar CSS 不适用于 Chrome 吗?

combobox - 组合框在第二次加载窗口时不显示记录

javascript - 查看和存储在 Controller 初始化之前加载

javascript - rethinkdb eqJoin 匹配

javascript - 如何在 HTML 的可竞争表中设置字符串的最大长度?

javascript - 将 React 函数组件传递给 .map() 有什么问题?

Extjs checkColumn