[英]show the Window in EXT JS
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 architect创建的标准应用程序结构,请在视图文件夹中创建具有类定义的文件。
因此,在点击处理程序中,您将只有:
// create instance of MyApp.view.LeftRightWIndow class
win = Ext.create('MyApp.view.LeftRightWIndow');
// display window
win.show();
目前,单击事件仅创建窗口对象而不显示它。 要在单击“ show-btn”后显示窗口,只需调用window对象的show()方法。 因此,尝试将win.show()
放在最后一行之前,如下所示:
...
me.callParent(arguments);
}
});
win.show();
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.