ExtJs 常用方法(alert confirm prompt show wait)

  • Post author:
  • Post category:其他

1、alert方法

[javascript] 
view plain
 copy

  1.        // 提示框  
  2. Ext.MessageBox.alert(“提示信息”,“hello world!!!”);  
  3. Ext.Msg.alert(‘ExtJs’);  
  4. alert(‘执行’);  


注:执行到ExtJs中的alert方法不会停止运行。不同于原生的js alert方法

2、confirm方法

[javascript] 
view plain
 copy

  1. <span style=“white-space:pre”>    </span>//询问框  
  2.     Ext.Msg.confirm(‘提示信息’,‘确认要删除这条信息吗?’,function(op){  
  3.         if(op == ‘yes’){  
  4.             alert(“确认删除”);  
  5.         }else{  
  6.             alert(“取消了”);  
  7.         }  
  8.     })  



3、prompt方法

[javascript] 
view plain
 copy

  1. <span style=“white-space:pre”>    </span>//输入框  
  2.     Ext.Msg.prompt(‘Name’‘Please enter your name:’function(btn, text){  
  3.         if (btn == ‘ok’){  
  4.             // process text value and close…  
  5.             alert(‘ok’);  
  6.         }  
  7.         console.info(btn); // 按钮  
  8.         console.info(text); //输入框内容  
  9.   
  10.     });  

4、show方法

[javascript] 
view plain
 copy

  1. //自定义提示信息  
  2.     Ext.Msg.show({  
  3.          title:‘Save Changes?’,  
  4.          msg: ‘You are closing a tab that has unsaved changes. Would you like to save your changes?’,  
  5.          buttons: Ext.Msg.YESNOCANCEL,  //显示的btn      
  6.          icon: Ext.Msg.QUESTION//图标 4种  INFO QUESTION ERROR WARNING  
  7.   
  8.     });  

5、wait方法

[javascript] 
view plain
 copy

  1. //等待框1  
  2.     /*var p = Ext.create(‘Ext.ProgressBar’, { 
  3.        renderTo: Ext.getBody(), 
  4.        width: 300 
  5.     }); 
  6.     // Wait for 5 seconds, then update the status el (progress bar will auto-reset) 
  7.     p.wait({ 
  8.         interval: 500, //bar will move fast! 
  9.         duration: 50000, 
  10.         increment: 15, 
  11.         text: ‘Updating…’, 
  12.         scope: this, 
  13.         fn: function(){ 
  14.             p.updateText(‘Done!’); 
  15.         } 
  16.     });*/  
  17.     //等待框2  
  18.     Ext.Msg.wait(‘提示信息’,‘我是内容’,{  
  19.     interval: 500,          //循环定时的间隔  
  20.         duration: 10000,        //总时长  
  21.         increment: 5,           //走完一次进度条次数  
  22.         text: ‘Updating…’,    //进度条上的文字  
  23.         scope: this,            //作用范围  
  24.         fn: function(){         //回调函数  
  25.             alert(‘更新成功!!!’);  
  26.         }  
  27.     })  

——————————–