如何在Sencha Architect中将控制器引用到视图
How to reference controller to a view in Sencha Architect?
我创建了一个带有一个面板的视图,它内部包含 2 个表单面板,即"欢迎"和"联系我们"。欢迎"包含一个按钮,并包含一个"点击"事件。按下该按钮应该隐藏"欢迎"表单,并应显示"联系我们"表单。我添加了一个控制器并在按钮上添加了事件。现在我的问题是如何从面板中选择单个窗体以及如何在控制器中引用这些单独的窗体。控制器引用具有"选择器"、"xtype"和"ref"等字段。我需要帮助来填写这些字段。我会感谢帮助我的人:)
'/*
*文件:应用程序/视图/联系我们.js * * 此文件由 Sencha Architect 版本 2.2.2 生成。 * http://www.sencha.com/products/architect/* * 此文件需要在独立许可下使用 Ext JS 4.2.x 库。 * Sencha Architect 的许可证不包括 Ext JS 4.2.x 的许可证。欲了解更多信息 * 详情请参阅 http://www.sencha.com/license 或联系 license@sencha.com。 * * 每次保存项目时,此文件都会自动生成。 * * 请勿手动编辑此文件。 */
Ext.define('MyApp.view.contactus', {
extend: 'Ext.panel.Panel',
alias: 'widget.contactus',
height: 724,
width: 479,
initComponent: function() {
var me = this;
Ext.applyIf(me, {
items: [
{
xtype: 'welcome',
frame: true,
height: 250,
html: 'Thank you for visiting our site! We welcome your feedback; itemId: 'welcomeid',
width: 400,
layout: {
align: 'middle',
type: 'hbox'
},
bodyPadding: 10,
title: 'Welcome',
dockedItems: [
{
xtype: 'toolbar',
flex: 1,
dock: 'top',
items: [
{
xtype: 'button',
itemId: 'contactusId',
margin: '0 0 50 50',
maxWidth: 70,
width: 70,
allowDepress: false,
preventDefault: false,
text: 'MyButton'
}
]
}
]
},
{
xtype: 'contactus',
frame: true,
height: 250,
hidden: true,
itemId: 'contactid',
margin: '10 0 0 0',
width: 400,
bodyPadding: 10,
title: 'Contact Us ',
tools: [
{
xtype: 'tool'
}
],
items: [
{
xtype: 'container',
layout: {
align: 'stretch',
type: 'hbox'
},
items: [
{
xtype: 'textfield',
flex: 1,
fieldLabel: 'Name',
labelWidth: 35,
allowBlank: false,
emptyText: 'FirstName'
},
{
xtype: 'textfield',
margin: '0 0 0 5',
width: 45,
fieldLabel: ''
},
{
xtype: 'textfield',
margin: '0 0 0 10',
width: 145,
allowBlank: false,
emptyText: 'LastName'
}
]
},
{
xtype: 'textfield',
anchor: '100%',
padding: '10 0 0 0',
fieldLabel: 'Email',
labelWidth: 50,
allowBlank: false,
vtype: 'email',
vtypeText: 'Enter a valid email Id!!'
},
{
xtype: 'container',
items: [
{
xtype: 'toolbar',
id: '',
margin: '0 0 0 280',
items: [
{
xtype: 'button',
itemId: 'saveId',
text: 'Save'
},
{
xtype: 'button',
itemId: 'cancelId',
text: 'Cancel'
}
]
}
]
}
]
}
]
});
me.callParent(arguments);
}
});
Ext.define('MyApp.controller.MyController', { extend: 'Ext.app.Controller',
refs: [
{
autoCreate: true,
ref: 'welcome',
selector: 'welcome',
xtype: ''
},
{
ref: 'contactus',
selector: 'contactus'
}
],
onButtonClick: function(button, e, eOpts) {
debugger;
var form=this.getContactus();
var form1=this.getWelcome();
form.show();
//debugger;
//form1.setDisabled(true);
//form1.disable(true);
form1.hide();
},
onSaveButtonClick1: function(button, e, eOpts) {
var form=this.getContactus();
var form1=this.getWelcome();
form.hide();
form1.show();
},
init: function(application) {
this.control({
"button#contactusId": {
click: this.onButtonClick
},
"button#saveId": {
click: this.onSaveButtonClick1
}
});
}
});'
您可以尝试从控制器进行 up() 或 down() 选择。下面是来自 souce 代码的示例代码片段。
onButtonClick: function(button, e, eOpts) {
debugger;
var thisView = this.getView();
var form= thisView.down('contactus');
var form1=thisView.down('welcome');
form.show();
//debugger;
//form1.setDisabled(true);
//form1.disable(true);
form1.hide();
}
相关文章:
- 引用已命名/未命名控制器中的角度控制器成员
- 如何通过不同的目录引用角度控制器
- 在控制器中使用具有函数引用的服务
- 如何在Sencha Architect中将控制器引用到视图
- AngularJS - 如何从ui-router引用子模块控制器
- 使用打字稿从回调中获取控制器引用
- 在控制器中声明的变量,带有“var”,但在控制器中引用为范围
- 如何从父控制器引用子作用域
- 无法引用控制器功能 ZF2
- 在控制器中访问$rootSope时的 angualrJS 未定义或空引用
- 在不使用作用域的情况下,我应该如何引用控制器函数中的服务
- 在控制器中使用实例化的对象引用
- ExtJS控制器引用视图获胜'不要使用不同的别名
- AngularJS,通过引用更新子控制器视图中的ng repeat
- Breeze扩展属性-如何在控制器阵列中引用
- 在Node.js中引用控制器中的Sequelize模型
- Angularjs在控制器中引用表单,获取html元素
- 控制器无法获取视图的引用
- 如何在没有循环引用的控制器之间共享对象/方法
- AngularJS -控制器函数顺序-一些引用不起作用