Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExtJS Element to Component

Tags:

extjs

I want to take an ExtJS element(div) retrieved from the DOM selector, and convert that to an ExtJS Component(a panel). How can I go about doing this? Thanks.

like image 275
needhelp Avatar asked Apr 08 '10 03:04

needhelp


People also ask

What is Component in Ext JS?

Advertisements. ExtJS UI is made up of one or many widgets called Components. Ext Js has various UI components defined that can be customized as per your requirements.

What is the use of xType in Ext JS?

xtype is an easy way to create Components without using the full class name. This is especially useful when creating a Ext. Container that contains child Components. An xtype is simply a shorthand way of specifying a Component - for example you can use xtype: 'panel' instead of typing out Ext.

What is autoEl in Ext JS?

autoEl. To change the element name of the outer el we can use the autoEl config option: new Ext.Component({ autoEl: 'form', }); It looks just the same as before but the markup has changed: <form id="..." class="green-box x-component x-component-default" ...></form>

What is the difference between an ext element and an ext component *?

Answer: An Ext. element encapsulates a DOM element, adding simple DOM manipulation facilities, normalizing for browser differences, whereas an Ext. component is the base class for all objects in Ext, such as controls, panels and stores.


1 Answers

You want to use the contentEl config. It places what is in the div into the panel.

<html>
  <head>
    <link rel="stylesheet" href="ext-3.1.1/resources/css/ext-all.css" />
    <script src="ext-3.1.1/adapter/ext/ext-base.js"></script>
    <script src="ext-3.1.1/ext-all-debug.js"></script>
    <script>
      Ext.BLANK_IMAGE_URL = 'ext-3.1.1/resources/images/default/s.gif';
      Ext.onReady(function(){
        var viewport = new Ext.Viewport({
          items: [{
            title: 'About Us',
            width: 200,
            height: 200,
            contentEl: 'about_us'
          }]
        });
      });
    </script>
  </head>
  <body>
    <div id="about_us">We are a great team to work with!</div>
  </body>
</html>

div content inside a panel

like image 84
Jonathan Julian Avatar answered Oct 17 '22 06:10

Jonathan Julian