Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ext JS: what is xtype good for?

Tags:

extjs

I see there are lot's of examples in Ext JS where instead of actually creating Ext JS objects, an object literal with an xtype property is passed in.

What is this good for? Where is the performance gain (if that's the reason) if the object is going to be created anyway?

like image 884
flybywire Avatar asked Feb 23 '10 11:02

flybywire


People also ask

What is xType in Ext JS?

xType defines the type of Ext JS UI component, which is determined during rendering of the component. For example, the element can be a textbox for which we have xType as textField or the element can have a numeric value only for which we have Numeric xType.

Is Ext JS still popular?

Even though ExtJS is well known among many coders, the technology is not globally spread. Nevertheless, this framework is most often used by big companies.

Is Ext JS any good?

For being over a decade old, Ext JS is still a good platform to develop many enterprise-grade (think intranet) applications.


1 Answers

xtype is a shorthand way to identify particular components: panel = Ext.Panel, textfield = Ext.form.TextField, etc. When you create a page or a form, you may use these xtypes rather than instantiate objects. For example,

items: [{    xtype: 'textfield',    autoWidth: true,    fieldLabel: 'something' }] 

Moreover, creating pages in this manner allows Ext JS to render lazily the page. This is where you see a "performance gain." Instead of creating a large number of components when the app loads, Ext JS renders components when the user needs to see them. Not a big deal if you have one page, but if you exploit tabs or an accordion, many pages are initially hidden and therefore the app will load more quickly.

Furthermore, you may create and register new components creating xtypes of your choosing. Ext JS will similarly render your components lazily.

You may also retrieve components by ID. Since your component (as well as the Ext JS components) may provide a bunch of nice behavior, it is sometimes convenient to search for and retrieve a component rather than a simple DOM element or node.

In short, xtypes identify components and components are a key aspect of Ext JS.

like image 96
Upperstage Avatar answered Oct 03 '22 02:10

Upperstage