Open source Invoicing Psi-extjs knowledge points (1)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.