我的表格有tabpanel(tabpanel有两个标签)。在表单上我有一个按钮(名称:开始),我想要:当选择第一个选项卡 - >选择第二个标签时按钮执行一个操作 - >另一个动作。
这是在控制器中:
showCreateForm: function(button) {
actions...
},
需要在控制器中写入什么条件?谢谢
答案 0 :(得分:0)
好问题....
ExtJs有一个优点,就是通过使用其路径和一些独特的属性来监听元素的动作,例如Inside_Some_XType-> TabPanel-> TabName-> Button,所以试试这种方式......
请参阅以下示例我之前在项目中所做的事情,它会帮助您
请参阅参考部分,我们是如何做到的......
Ext.define("XCP.controller.LoginController", {
extend: "Ext.app.Controller",
views: ["LoginScreen"],
refs: [
//Ext.ComponentQuery
{ ref: "userName", selector: "login > textfield[id=usernametext]" },
{ ref: "password", selector: "login > textfield[inputType=password]" },
{ ref: "homeScreen", selector: "home" }
],
init: function () {
this.control({
"login > button[text=Submit]": {
click: this.onLoginButtonClicked
},
"login > button[text=Reset]": {
click: this.onResetButtonClicked
},
"#logoutbutton": {
click: this.onLogoutButtonClicked
}
});
},
onLogoutButtonClicked: function () {
this.application.viewport.getLayout().setActiveItem(0);
},
onResetButtonClicked: function () {
alert("Reset");
},
onLoginButtonClicked: function () {
if (this.getUserName().getValue() == "admin" &&
this.getPassword().getValue() == "admin") {
if(!this.getHomeScreen())
this.application.viewport.add({ xtype: "home", id: "homescreen" });
this.application.viewport.getLayout().setActiveItem(1);
}
else
alert("Invalid credentials");
}
});
否则你应该为每个标签中的按钮生成默认和唯一ID ...它没有高度重新开始。
答案 1 :(得分:0)
refs: [
{ ref: "sellBook", selector: "bookgrid>TabPanel>Tab1>button[action=check-book]"},
{ ref: "buyBook", selector: "bookgrid>TabPanel>Tab2>button[action=check-book]" },
],)
init: function ()
{ this.control(
{ "bookgrid > button[action=check-book]": { click: this.sellBookShow },
{ "bookgrid> button[action=check-book]": { click: this.buyBookShow }, })