ExtJs2.0學習系列(1)--Ext.MessageBox

來源:互聯網
上載者:User

大家都知道,剛開始搞extjs的時候,很是有點困難,所以本人在新手剛入門後準備了這個系列的文章。

個人認為用extjs做後台很不錯,布局比較完美!

1.Ext.MessageBox.alert()方法

有四個參數,為簡單起見,主要介紹前面三個參數:

alert( title , msg , function(){} )

其中title,msg為必選參數,function為選擇性參數,在關閉快顯視窗後觸發。

Ext.MessageBox.alert("title","msg");

Ext.MessageBox.alert("title","msg",function(){alert("關閉對話方塊後彈出!")});

2.Ext.MessageBox.confirm()方法

基本上同alert()方法一模一樣。

注意這點:

Ext.MessageBox.confirm("title","msg",function(e){alert(e);});

這個參數e是什嗎?它是你點擊的彈出框的按鈕的值,三種值:yes,no,cancel.Alert()方法也是如此,不過只有兩種值:ok,cancel.

3.Ext.MessageBox.prompt()方法

有六個參數,比前面alert方法多一個傳回值和是否多行。

Ext.MessageBox.prompt("title","msg");

Ext.MessageBox.prompt("title","msg",function(e,text){alert(e+"-"+text);});
//輸入"qianxudetianxia",點擊ok按鈕,彈出ok-qianxudetianxia

Ext.MessageBox.prompt("title","msg",function(e,text){alert(e+"-"+text);},this,true);
//true為多行,this表示範圍

4.Ext.MessageBox.show()方法

功能很強大,採用config配置形式,比前面的方法使用更方便。

參數很多,在此列舉最常用的配置參數:

1.animEl:對話方塊彈出和關閉時的動畫效果,比如設定為“id1”,則從id1處彈出併產生動畫,收縮則相反

2.buttons:彈出框按鈕的設定,主要有以下幾種:Ext.Msg.OK,

Ext.Msg.OKCANCEL,
Ext.Msg.CANCEL,
Ext.Msg.YESNO,
Ext.Msg.YESNOCANCEL

你也可以自訂按鈕上面的字:{"ok","我本來是ok的"}。

若設為false,則不顯示任何按鈕.

3.closable:如果為false,則不顯示右上方的小叉叉,預設為true。

4.msg:"訊息的內容"

5.title:"標題"

6.fn:關閉彈出框後執行的函數

7.icon:彈出框內容前面的表徵圖,取值為Ext.MessageBox.INFO,

Ext.MessageBox.ERROR,
Ext.MessageBox.WARNING,
Ext.MessageBox.QUESTION

8.width:彈出框的寬度,不帶單位

9.prompt:設為true,則彈出框帶有輸入框

10.multiline:設為true,則彈出框帶有多行輸入框

11.progress:設為true,顯示進度條,(但是是死的)

12.progressText:顯示在進度條上的字

13.wait:設為true,動態顯示progress

14.waitConfig:配置參數,以控制顯示progress

example:

Ext.MessageBox.show({
  title:"標題",
  msg:"內容的訊息",
  buttons:{"ok":"我不再顯示OK了"},
  fn:function(e){alert(e);},
  animEl:"test1",
  width:500,
  icon:Ext.MessageBox.INFO,
  closable:false,
  progress:true,
  wait:true,
  progressText:"進度條"
 //prompt:true
 //multiline:true
});

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.