0

在最基本的形式中,EXTJS 提示符是这样的:

Ext.MessageBox.prompt('Name', 'Please enter your name:', showResultText);
});

现在在我的应用程序中,有一个样式表将所有消息框呈现为灰色。并且按钮也是灰色的,因此按钮与提示框的灰色背景无法区分。那么有没有办法自定义提示,以便我可以在按钮 Ok 和 Cancel 周围放置边框?我的另一个问题是:有没有办法在提示框中放置一个帮助图标?在 MessageBox 中,有一个名为 ICON 的配置选项。有没有办法在提示中使用这个选项?

4

1 回答 1

0

1)在提示框中添加图标:

Ext.MessageBox.prompt只是提供一些默认选项的包装器方法,Ext.MessageBox.show因此您可以创建一个不同的包装器方法来使用您自己的选项,然后您可以轻松地Ext.MessageBox.prompt使用自定义提示包装器覆盖

var customPrompt = function(title, msg, fn, scope, multiline, value){
     Ext.MessageBox.show({
          title : title,
          msg : msg,
          buttons: Ext.MessageBox.OKCANCEL,
          fn: fn,
          minWidth: Ext.MessageBox.minPromptWidth,
          scope : scope,
          prompt:true,
          multiline: multiline,
          value: value,
          icon : Ext.MessageBox.QUESTION
     });
     return Ext.MessageBox;
};

customPrompt('title', 'message');

2)改变按钮的样式:

按钮元素存储在对话框组件中以供参考,因此您可以获取这些元素并将自定义类添加到按钮

var dlg =  Ext.MessageBox.getDialog();
var buttons = dlg.buttons;
for(i = 0; i < buttons.length; i++) {
     buttons[i].addClass('custom-css-class');   // class that will do styling of buttons
}
于 2013-04-07T18:34:33.150 回答