ExtJS 4或4.1 MessageBox自定义按钮

Ekr*_*ĞUL 6 extjs4 extjs4.1

Ext.MessageBox.show({
    title:'Messagebox Title',
    msg: 'Are you sure want to delete?',
    buttons: {yes: "Some Button 1",no: "Some Button 2",cancel: "Some Button 3"}
});
Run Code Online (Sandbox Code Playgroud)

ExtJS 4或4.1不支持此代码.按钮没有显示.

use*_*719 20

刚刚发现了如何做到这一点,希望它可以帮助某人.如您所见,您可以随意处理按钮.请注意,框架默认只有4个按钮,这是一个不容易克服的限制.在源中有多个循环硬编码从0到<4.

Ext.MessageBox.show({
    title:'Messagebox Title',
    msg: 'Are you sure want to delete?',
    buttonText: {yes: "Some Button 1",no: "Some Button 2",cancel: "Some Button 3"},
    fn: function(btn){
        console.debug('you clicked: ',btn); //you clicked:  yes
    }
});
Run Code Online (Sandbox Code Playgroud)


nsc*_*rob 4

您不能在方法 show 中执行此操作,因为方法中的按钮配置将标识要显示的按钮的数字作为参数。\n您可以做的是预定义消息框,然后显示它。

\n\n
 var win = Ext.create('Ext.window.MessageBox', {\n     width:300,\n     height: 100,\n     buttons: [\n      {text: 'My button 1'},{\n        text: 'My button 2'}\n    ]\n});\n\nwin.show({\n     title:'Messagebox Title',\n     msg: 'Are you sure want to delete?',\n    icon: Ext.Msg.QUESTION\n});\xe2\x80\x8b\n
Run Code Online (Sandbox Code Playgroud)\n