Saturday, August 11, 2012
ExtJS–Message Box
Ext.Msg is a singleton based on Ext.MessageBox class generating different types of message boxes.
There are four types of Message boxes
- alert
- Display a read-only message box with OK button (similar to javascript alert).The live example can found here
Ext.Msg.alert('Alert Box',
'This is a alert box.Html element
');
// To capture feedback
Ext.Msg.alert('Alert Box', 'This box will capture feedback.',
function(buttonId) {
Ext.Msg.alert('Feeback', "Button Clicked : " + buttonId);
});- confirm
Ext.Msg.confirm() displays a confirmation message box. It displays a message with Yes and No button. The code snippet is given below.The live example can be found here
Ext.Msg.confirm('Confirm Box', 'Do you wish to continue?', function(
buttonText) {
if (buttonText == "no") {
Ext.Msg.alert('No', "You clicked no");
}
if (buttonText == "yes") {
Ext.Msg.alert('Yes', "You clicked yes");
}
});- prompt
Prompt box can be used to get user input similar to javascript’s prompt. It has “ok” and “cancel”. The code snippet is given belowExt.Msg.prompt('Prompt', "Enter your name? ", function(btnTxt,The live example can be found here
inputText) {
if (btnTxt == 'ok') {
Ext.Msg.alert("Prompt ", "Your name is "+inputText)
}
});- Displaying a Custom Message Box
Ext.Msg.show() should be used display a custom message box. We can configure the title, msg, dimension, buttons, call back function, icon.
List of button types
- Ext.MessageBox.OK
- Ext.MessageBox.YES
- Ext.MessageBox.NO
- Ext.MessageBox.CANCEL
Icon can be
- Ext.MessageBox.INFO
- Ext.MessageBox.WARNING
- Ext.MessageBox.QUESTION
- Ext.MessageBox.ERROR
Ext.Msg.show({The live example can be found here
title : 'Show Message Box',
msg : 'Please enter your address',
width : 300,
buttons : Ext.Msg.OKCANCEL,
multiline : true,
icon : Ext.window.MessageBox.INFO
});
Subscribe to:
Post Comments (Atom)
Thanks very helpful post
ReplyDelete