Ext.js – Window

Ext.js - Window

This UI component of Ext.js Window is to create a window, which should pop up when any event occurs. Window is basically a panel, which should appear when any event occurs as a button/link click or hover over.

Syntax

Following is a simple syntax to create a window.

win = new Ext.Window({ properties });

Example

Following is a simple example showing an email window.

<!DOCTYPE html>
<html>
   <head>
      <link href = "https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/classic/theme-classic/resources/theme-classic-all.css" 
         rel = "stylesheet" />
      <script type = "text/javascript" 
         src = "https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/ext-all.js"></script>
      
      <script type = "text/javascript">
         Ext.onReady(function() {
            win = new Ext.Window ({
               title:'Email Window',
               layout:'form',
               width:400,
               closeAction:'close',
               target : document.getElementById('buttonId'),
               plain: true,
               
               items: [{
                  xtype : 'textfield',
                  fieldLabel: 'To'
               },{
                  xtype : 'textfield',
                  fieldLabel: 'CC'
               },{
                  xtype : 'textfield',
                  fieldLabel: 'BCC'
               },{
                  xtype : 'textfield',
                  fieldLabel: 'Subject'
               },{
                  xtype : 'textarea',
                  fieldLabel: 'Email Message'
               }],
               
               buttons: [{
                  text: 'Save Draft',
                  handler: function(){Ext.Msg.alert('Save Draft', 'Your msg is saved');}
               },{
                  text: 'Send',
                  handler: function(){Ext.Msg.alert('Message Sent', 'Your msg is sent');}
               },{
                  text: 'Cancel',
                  handler: function(){
                     win.close(); Ext.Msg.alert('close', 'Email window is closed');}
               }],
               buttonAlign: 'center',
            });
            Ext.create('Ext.Button', {
               renderTo: Ext.getElementById('buttonId'),
               text: 'Click Me',
               
               listeners: {
                  click: function() {
                     win.show();
                  }
               }
            });
         });
      </script>
   </head>
   
   <body>
      <p> Click the button to see window </p>
      <div id = "buttonId"></div>
   </body>
</html>

The above program will produce the following result −

Ext.js - Window

Next Topic : Click Here

Leave a Reply