Clear Up
SharpKit Reference

MessageBox Class

Utility class for generating different styles of message boxes. The singleton instance, Ext.MessageBox alias Ext.Msg can also be used.

Note that a MessageBox is asynchronous. Unlike a regular JavaScript alert (which will halt browser execution), showing a MessageBox will not cause the code to stop. For this reason, if you have code that should only run after some user feedback from the MessageBox, you must use a callback function (see the function parameter for show for more details).

Basic alert

  
    Ext.Msg.alert('Status', 'Changes saved successfully.');
            

Prompt for user data and process the result using a callback

  
    Ext.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
            if (btn == 'ok'){
            // process text value and close...
            }
            });
            

Show a dialog using config options

  
    Ext.Msg.show({
            title:'Save Changes?',
            msg: 'You are closing a tab that has unsaved changes. Would you like to save your changes?',
            buttons: Ext.Msg.YESNOCANCEL,
            icon: Ext.Msg.QUESTION
            });
            

Namespace: Ext.window

Derived Types

Methods

Name Description
alert(JsString, JsString, Delegate, object) Displays a standard read-only message box with an OK button (comparable to the basic JavaScript alert prompt). If a callback function is passed it will be called after the user clicks the button, and the id of the button that was clicked will be passed as the only parameter to the callback (could also be the top-right close button, which will always report as "cancel").
confirm(JsString, JsString, Delegate, object) Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's confirm). If a callback function is passed it will be called after the user clicks either button, and the id of the button that was clicked will be passed as the only parameter to the callback (could also be the top-right close button, which will always report as "cancel").
progress(JsString, JsString, object) Displays a message box with a progress bar. You are responsible for updating the progress bar as needed via updateProgress and closing the message box when the process is complete.
prompt(JsString, JsString, Delegate, object, object, object) Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to JavaScript's prompt). The prompt can be a single-line or multi-line textbox. If a callback function is passed it will be called after the user clicks either button, and the id of the button that was clicked (could also be the top-right close button, which will always report as "cancel") and the text that was entered will be passed as the two parameters to the callback.
show(object) Displays a new message box, or reinitializes an existing message box, based on the config options passed in. All display functions (e.g. prompt, alert, etc.) on MessageBox call this function internally, although those calls are basic shortcuts and do not support all of the config options allowed here. Example usage:
  Ext.Msg.show({
            title: 'Address',
            msg: 'Please enter your address:',
            width: 300,
            buttons: Ext.Msg.OKCANCEL,
            multiline: true,
            fn: saveAddress,
            animateTarget: 'addAddressBtn',
            icon: Ext.window.MessageBox.INFO
            });
            
updateProgress(object, object, object) Updates a progress-style message box's text and progress bar. Only relevant on message boxes initiated via progress or wait, or by calling show with progress: true.
wait(JsString, object, object) Displays a message box with an infinitely auto-updating progress bar. This can be used to block user interaction while waiting for a long-running process to complete that does not have defined intervals. You are responsible for closing the message box when the process is complete.

Properties

Name Description
buttonText An object containing the default button text strings that can be overriden for localized language support. Supported properties are: ok, cancel, yes and no. Generally you should include a locale-specific resource file for handling language support across the framework. Customize the default text like so:
Ext.window.MessageBox.buttonText.yes = "oui"; //french
            
Defaults to: {ok: "OK", yes: "Yes", no: "No", cancel: "Cancel"}
CANCEL Button config that displays a single Cancel button Defaults to: 8
defaultTextHeight The default height in pixels of the message box's multiline textarea if displayed. Defaults to: 75
ERROR The CSS class that provides the ERROR icon image Defaults to: "x-message-box-error"
INFO The CSS class that provides the INFO icon image Defaults to: "x-message-box-info"
minProgressWidth The minimum width in pixels of the message box if it is a progress-style dialog. This is useful for setting a different minimum width than text-only dialogs may need. Defaults to: 250
minPromptWidth The minimum width in pixels of the message box if it is a prompt dialog. This is useful for setting a different minimum width than text-only dialogs may need. Defaults to: 250
NO Button config that displays a single No button Defaults to: 4
OK Button config that displays a single OK button Defaults to: 1
OKCANCEL Button config that displays OK and Cancel buttons Defaults to: 9
QUESTION The CSS class that provides the QUESTION icon image Defaults to: "x-message-box-question"
WARNING The CSS class that provides the WARNING icon image Defaults to: "x-message-box-warning"
YES Button config that displays a single Yes button Defaults to: 2
YESNO Button config that displays Yes and No buttons Defaults to: 6
YESNOCANCEL Button config that displays Yes, No and Cancel buttons Defaults to: 14
© Copyright 2005-2011 SharpKit. All rights reserved.