Introduction
This series of blogs originated in the PSI QQ group where students complained that there was no comment in the JS code, so I decided to add comments. At the same time I was thinking: a lot of questions about ExtJS and not very familiar with ExtJS basic knowledge points related, so I decided to write this series of blog.
Note: These knowledge points are only applied to the PSI code, not the ExtJS development encyclopedia.
Ext.define
This is what I think is most important in ExtJS all the points of knowledge, because it must appear in almost every PSI JS code.
In layman's words, ext.define is the definition of a new class. Because JS itself does not have the class of the native type, so the EXTJS internal simulation of the class system, mainly to achieve from a class to inherit to generate a new class.
Ext.define ("PSI. App ", {config: {userName:" "},//The following code omitted
The use of config is very special, which can make people confused.
1, the property inside the config will automatically generate a Get method, such as the above UserName, will generate a GetUserName () method.
The following is an example of a call:
var me = this; ["Current User: <span style= ' color:red ' >" + me.getusername () + "</span>"]
2, config corresponding to the use of this class when creating, you can be passed as an additional parameter to the class, for example:
var app = Ext.create ("PSI. App ", {userName:" {$loginUserName} "});
It is particularly important to use the Ext.create method to create class and not use new
The above class is used by creating an instance from the Create method. Ext.defin can also define static methods.
Ext.define ("PSI. MsgBox ", { statics: { showinfo : function (Info, func) { ext.msg.show ({ title: "Tips", msg: info, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK, modal: true, fn: function () { if (func) { func (); } } } ); }, // the following code slightly
A static method can be defined by statics. The invocation examples of the static methods defined above are:
Psi. Msgbox.showinfo ("Please select an organization to edit");
Call static method, do not need to use ext.create
The extend is implemented from an existing class inheritance, for example:
Ext.define ("PSI. Inventory.initinventoryeditform ", {extend:" Ext.window.Window ",//the following code slightly
This defines a class:PSI.Inventory.InitInventoryEditForm, whose parent class is Ext.window.Window
Open source Invoicing Psi-extjs knowledge points (1)