Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xtype instead of alias in class definition

Is there any difference between the two following class definition methods?

Ext.define("Test", {
  extend: "Ext.grid.Panel",
  xtype: "test"
});

Ext.define("Test", {
  extend: "Ext.grid.Panel",
  alias: "widget.test"
});
like image 274
Handsome Nerd Avatar asked Dec 14 '14 11:12

Handsome Nerd


2 Answers

As Eddy already stated, there is no difference in the result in case of a xtype.

But the alias property can more then a xtype...

The main difference is that alias can be used to define all sort of aliases (widgets, plugins, features, layouts, etc.) while xtype already is a specific shorthand for a alias type, a widget. So if you use xtype you can only define widgets, nothing else. In addition the alias property makes the code a bit more readable and should therefore be the first choice when writing class definitions.

Here are the common aliases of versions 4.2.3

  • association
  • axis
  • data
  • direct
  • editing
  • feature
  • formaction
  • idgen
  • layout
  • plugin
  • proxy
  • reader
  • selection
  • series
  • state
  • store
  • widget
  • writer
like image 189
sra Avatar answered Nov 19 '22 20:11

sra


It is said that the alias is faster, but I don't think you will notice. I use alias when defining classes and xtype when creating objects, just a personal convention, so I don't get confused.

like image 4
Eddy Avatar answered Nov 19 '22 20:11

Eddy