extjs各種彈出框

來源:互聯網
上載者:User

標籤:style   io   ar   color   os   sp   java   for   strong   

1.ExtJs之訊息框:
  文法:Ext.MessageBox.alert(String title, String msg,Function fn, Obejct scope);   參數定義: 
  
  • title: 標題
  • msg: 提示內容
  • fn: 提示框關閉之後自動調用的回呼函數
  • scope: 範圍,用於指定this指向哪裡
[javascript] view plaincopy
  1. Ext.MessageBox.alert("提示框","這是一個提示框");  
  2. Ext.MessageBox.alert("提示框","這是一個提示框",function(){    
  3.      alert("提示框關閉")    
  4. });  
2. ExtJs 之輸入框 
  文法:Ext.MessageBox.prompt(String title, String msg,Function fn,Object scope,Boolean/Number multiline,String defaulttext); 
  參數定義:
  • title: 標題
  • msg: 提示內容
  • fn: 提示框關閉之後自動調用的回呼函數
  • scope: 範圍,用於指定this指向哪裡
  • Boolean/Number:如果為true或為數字,則表示允許輸入多行或者指定預設高度
  • defaulttext :輸入框預設常值內容
[javascript] view plaincopy
  1. Ext.MessageBox.prompt("輸入框","請輸入名字:",function(bu,txt){    
  2.      Ext.MessageBox.alert("Result","你點擊的是"+bu+"按鈕,<br> 輸入的內容為:"+txt);    
  3. },this,300); 
3.ExtJs之確認框 
文法: 
  Ext.MessageBox.confirm(String title, String msg,Function fn, Object scope); 
  參數定義:    
  • title: 標題
  • msg: 提示內容
  • fn: 提示框關閉之後自動調用的回呼函數
  • scope: 範圍,用於指定this指向哪裡
[javascript] view plaincopy
  1. Ext.MessageBox.confirm("確認","請點擊下面的按鈕作出選擇",function(btn{    
  2.         Ext.MessageBox.alert("你單擊的按鈕是:"+btn);    
  3. }); 

4. ExtJs之自訂訊息框 
  文法:      Ext.MessageBox.show(Object config);  config屬性說明: 

  • title : 訊息框標題列
  • msg:訊息內容
  • width:訊息框的寬度
  • multiline: 是否顯示多行文本
  • closable:是否顯示關閉按鈕
  • buttons:按鈕
  • icon:表徵圖
  • fn:回呼函數
[javascript] view plaincopy
  1. var config ={    
  2.     title:"自訂對話方塊",    
  3.     msg:"這是一個自訂對話方塊",    
  4.     width:400,    
  5.     multiline:true,    
  6.     closable:false,    
  7.     buttons:Ext.MessageBox.YESNOCANCEL,    
  8.     icon:Ext.MessageBox.QUESTION,    
  9.     fn:  function(btn,txt){    
  10.    Ext.MessageBox.alert("Result","你點擊了‘yes‘按鈕<br>,輸入的值是:"+txt);    
  11.     
  12.  };    
  13. Ext.MessageBox.show(config); 

 

注意:在ExtJs.MessageBox中已經定義了buttons的取值.如下 

引用OK:只有"確定"按鈕  CANCEL:只有"取消"按鈕  OKCANCEL:有"確定"和"取消"按鈕  YESNO: 有"是"和"否"按鈕  YESNOCANCEL:有"是"、"否"和"取消"按鈕 
icons取值如下 
引用  INFO:資訊表徵圖    WARNING:警告圖示    QUESTION:詢問表徵圖    ERROR:錯誤表徵圖5.ExtJs之進度條對話方塊     進度條對話方塊也是自訂訊息框的一種,只是在配置Config時添progress=true即可,同時在設定其他相關資訊,比如進度提示。  [javascript] view plaincopy
  1. Ext.MessageBox.show({    
  2.        title:‘請等待片刻‘,    
  3.        msg:‘正在附加元件目....‘,    
  4.        progressText:‘正在初始化...‘,    
  5.        Width:300,    
  6.        progress:true,    
  7.        closable:false    
  8.    });    
  9.   var f = function(v){    
  10.       return function(){    
  11.         if(v == 12){    
  12.             Ext.MessageBox.hide();    
  13.             Ext.MessageBox.alert(‘完成‘,‘所有項目載入完成!‘);    
  14.          }else{    
  15.              var i = v/11;    
  16.             Ext.MessageBox.updateProgress(i,Math.round(100*i)+‘%以完成‘);    
  17.           }    
  18.       };    
  19.  };    
  20.   for(var i=0; i<13;i++){    
  21.     setTimeout(f(i),i*500);    
  22.   } 

解 析上述代碼中ProgressText屬性是進度條滾動之前最初的文本,滾動進程由updateProgress(Number value,String progressText)方法來定義,參數value是從0-1之間的小數,表示進度百分比;progressText則表示進度條滾動過程中的文本提示資訊。

 

6.ExtJs之訊息框動畫效果 [javascript] view plaincopy
  1. var config = {    
  2.        title:"飛出的訊息框",    
  3.        msg:"這是一個自訂對話方塊,是飛出來的哦",    
  4.        width:400,    
  5.        multiline:true,    
  6.        closable:false,    
  7.        buttons:Ext.MessageBox.YESNOCANCEL,    
  8.        icon:Ext.MessageBox.QUESTION,    
  9.        animEl:"fly"    
  10.      };    
  11.      Ext.MessageBox.show(config); 
PS:彈框的寬度都是固定的,很多時候都會影響美觀,相信很多人都會想著如何改變彈框的寬度。
Ext源碼 1、progress : function(title, msg, progressText){             this.show({                 title : title,                 msg : msg,                 buttons: false,                 progress:true,                 closable:false,                 minWidth: this.minProgressWidth,                 progressText: progressText             });             return this;         },    wait : function(msg, title, config){             this.show({                 title : title,                 msg : msg,                 buttons: false,                 closable:false,                 wait:true,                 modal:true,                 minWidth: this.minProgressWidth,                 waitConfig: config             });             return this;         }, 修改寬度的代碼為:Ext.MessageBox.minProgressWidth = 400; 例:         Ext.MessageBox.minPromptWidth = 400;         Ext.MessageBox.prompt("補充需求資訊", "需求分析", analysisreq, this, 250, vanalysisReq);

extjs各種彈出框

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.