带有自定义按钮的ExtJs消息框
如何使用自定义按钮显示ExtJS消息框 我想要一个带有自定义消息和“取消”和“停用”按钮的消息框。 请给出一些想法带有自定义按钮的ExtJs消息框,extjs,extjs3,Extjs,Extjs3,如何使用自定义按钮显示ExtJS消息框 我想要一个带有自定义消息和“取消”和“停用”按钮的消息框。 请给出一些想法 buttons: [{ text: "Cancel", handler: function () { Ext.MessageBox.hide(); //submitTicketForm(); } },{ text: "Deactivate", handler: function () { Ext
buttons: [{
text: "Cancel",
handler: function () {
Ext.MessageBox.hide();
//submitTicketForm();
}
},{
text: "Deactivate",
handler: function () {
Ext.MessageBox.hide();
}
}],
我这样使用它,但没有任何按钮。MessageBox是一个内部管理窗口的单个实例,用于提示、显示、警报等 您可以通过如下方式为show传入字符串来更改buttonText:
buttons: {ok: "Foo", cancel: "Bar"}
Ext.define('App.view.MyDialog', {
/**
* Shows the dialog.
*/
show: function() {
var dialog = Ext.create('Ext.window.MessageBox', {
buttons: [{
text: 'baz',
iconCls: 'icon-add',
handler: function() {
dialog.close();
}
}]
});
dialog.show({
title: 'foo!',
msg: '<p>bar?</p>',
icon: Ext.MessageBox.WARNING
});
dialog.setHeight(160);
dialog.setWidth(420);
}
});
参考:
在ExtJS 4中,您可以制作自己的组件,如下所示:
buttons: {ok: "Foo", cancel: "Bar"}
Ext.define('App.view.MyDialog', {
/**
* Shows the dialog.
*/
show: function() {
var dialog = Ext.create('Ext.window.MessageBox', {
buttons: [{
text: 'baz',
iconCls: 'icon-add',
handler: function() {
dialog.close();
}
}]
});
dialog.show({
title: 'foo!',
msg: '<p>bar?</p>',
icon: Ext.MessageBox.WARNING
});
dialog.setHeight(160);
dialog.setWidth(420);
}
});
使用“buttonText”而不是“button”
buttonText: {ok: 'Deactivate', cancel: 'Cancel'},
fn: function(btn) {
if (btn === 'ok') {
Ext.MessageBox.hide();
} else {
Ext.MessageBox.hide();
}
}
在ExtJS 4和ExtJS 5中,要为按钮设置自定义文本,需要同时使用
按钮
和按钮文本
配置:
buttons: [{
Ext.Msg.OK
}],
buttonText: {
ok: "Custom text"
},
fn: function() {
// ...handle OK button
}
感谢您的重播..工作正常,但如何添加处理程序,当我尝试为一个按钮添加处理程序时,按钮没有得到...感谢此:
fn:function(btn){console.log('btn'+btn);}
我认为重要的是要注意,buttons
属性只有在创建新的消息框时才可用。如果您使用的是Ext.Msg.show({config})
则没有按钮
属性!您可以定义一个类并在其中创建一个组件。为什么不扩展一个Messagebox呢?