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({
title : 'Show Message Box',
msg : 'Please enter your address',
width : 300,
buttons : Ext.Msg.OKCANCEL,
multiline : true,
icon : Ext.window.MessageBox.INFO
});
The live example can be found here
Saturday, December 17, 2011
ExtJS 4– Adding Library and Testing
Download the ExtJS 4 from here.
Unzip to a folder. The file/folder required are as shown in the screenshot below.
Copy “ext-all-debug-w-comments.js” and resources folder to the web-application being developed.
My examples are based on grails framework. Details are available here
The folder structure for a typical grails integration will be
Adding library to the page in <head> section (html, jsp or gsp).
To test whether the extjs has be included in page. Add the following code below the above code.
The ExtJS onReady is fired once the page DOM is loaded in browser. Please refer ExtJS documentation for further insight.
All in all the head section of the page should look like this
Ignore the <meta….>, this is specific to grails.