EXTJS学习(二)Message

上一节 EXTJS学习(一)
上一节简单介绍了下EXTJS,接下来学习其中的消息类
这里面有以下几个方法
1.Alert
alertString title, String msg, [Function fn], [Object scope] ) : 
这里面后面两个参数是非必须的,以下是例子
 Ext.MessageBox.alert('Status', 'Changes saved successfully.', showResult);
 function showResult(btn){
        Ext.Msg('Button Click', btn);
    };
2.confirm
confirmString title, String msg, [Function fn], [Object scope] ) :
这里的用法和alert相似
 Ext.MessageBox.confirm('Confirm', 'Are you sure you want to do that?', showResult);
 function showResult(btn){
        Ext.Msg('Button Click', btn);
    };
3.Prompt
promptString title, String msg, [Function fn], [Object scope], [Boolean/Number multiline] ) : Ext.MessageBox
Ext.MessageBox.prompt('Name', 'Please enter your name:', showResultText);
function showResultText(btn, text){
        Ext.Msg('Button Click', text);
    };
其中第一个参数是按钮的参数,第二个参数是传递的值,也就是输入之后得到的值
4.Multi-line Prompt
Ext.MessageBox.show({
           title: 'Address',
           msg: 'Please enter your address:',
           width:300,
           buttons: Ext.MessageBox.OKCANCEL,
           multiline: true,
           fn: showResultText,
           animEl: 'mb3',
           icon: Ext.MessageBox.QUESTION
       });

function showResultText(btn, text){
        Ext.Msg('Button Click', text);
    };
其中title是显示的标题,msg是现实的提示消息,width是输入框的宽度,button这里是消息框中显示的按钮,multiline是否多行输入,fn处理函数,icon显示的图标
5.Yes/No/Cancel
Ext.MessageBox.show({
           title:'Save Changes?',
           msg: 'You are closing a tab that has unsaved changes. <br />Would you like to save your changes?',
           buttons: Ext.MessageBox.YESNOCANCEL,
           fn: showResult,
           animEl: 'mb4',
           icon: Ext.MessageBox.QUESTION
       });
6.Progress Dialog

 Ext.MessageBox.show({
           title: 'Please wait',
           msg: 'Loading items...',
           progressText: 'Initializing...',
           width:300,
           progress:true,
           closable:false,
           animEl: 'mb6'
       });

       // this hideous block creates the bogus progress
       var f = function(v){
            return function(){
                if(v == 12){
                    Ext.MessageBox.hide();
                    Ext.example.msg('Done', 'Your fake items were loaded!');
                }else{
                    var i = v/11;
                    Ext.MessageBox.updateProgress(i, Math.round(100*i)+'% completed');
                }
           };
       };
       for(var i = 1; i < 13; i++){
           setTimeout(f(i), i*500);
       }
下面的一部分是采用定时来刷新进度条,以及显示进度条
7.Wait Dialog
Ext.MessageBox.show({
           msg: 'Saving your data, please wait...',
           progressText: 'Saving...',
           width:300,
           wait:true,
           waitConfig: {interval:200},
           icon:'ext-mb-download', //custom class in msg-box.html
           animEl: 'mb7'
       });
        setTimeout(function(){
            //This simulates a long-running operation like a database save or XHR call.
            //In real code, this would be in a callback function.
            Ext.MessageBox.hide();
            Ext.example.msg('Done', 'Your fake data was saved!');
        }, 8000);
警告里面大概就是这些了,更多的信息可以参考官方的文档

posted @ 2008-03-29 11:36  dail  阅读(3060)  评论(0编辑  收藏  举报