在我的程序中有一个带有两个TextField和一个Button的'Screen'。
按钮有这个监听器;
listeners: {
tap: function (as, e, eOpts ) {
Ext.Viewport.animateActiveItem({xtype: 'clientlist'},{ type:'flip'})},
},
}
按下按钮我转到另一个屏幕......
在第二个屏幕中我想使用一个标签,我想在第一个屏幕上看到我写的文字..那么如何在新屏幕中移植文本(在第一个屏幕的文本框中)? / p>
非常感谢!
答案 0 :(得分:1)
遵循MVC格式:
查看:
Ext.define('MyApp.view.FirstScreen', {
extend: 'Ext.Panel',
config: {
items: [
{
xtype: 'textfield',
itemId: 'textField1',
label: 'Field'
},
{
xtype: 'textfield',
itemId: 'textField2',
label: 'Field'
},
{
xtype: 'button',
itemId: 'mybutton1',
text: 'click me'
},
{
xtype: 'titlebar',
docked: 'top',
title: 'First Screen'
}
]
}
});
// Client List (Second Screen)
Ext.define('MyApp.view.ClientList', {
extend: 'Ext.Panel',
alias: 'widget.clientlist',
config: {
itemId: 'clientList',
items: [
{
xtype: 'titlebar',
docked: 'top',
title: 'Client List'
}
]
}
});
控制器:
Ext.define('MyApp.controller.MyController1', {
extend: 'Ext.app.Controller',
config: {
refs: {
textField1: '#textField1',
textField2: '#textField2',
clientList: {
autoCreate: true,
selector: '#clientList',
xtype: 'clientlist'
}
},
control: {
"button#mybutton1": {
tap: 'onMybutton1Tap'
}
}
},
onMybutton1Tap: function(button, e, options) {
var me = this,
clientList = me.getClientList(),
textField1_val = me.getTextField1().getValue(),
textField2_val = me.getTextField2().getValue();
Ext.Viewport.animateActiveItem(clientList,{ type:'flip'});
// Do what you need to do with the values from your
// first screen in your client list
clientList.setHtml('textField1_data: '+textField1_val+'<br>textField2_data: '+ textField2_val);
}
});