"ExtJS" About custom components

Source: Internet
Author: User
Tags naming convention

first, naming normsUsing a uniform naming convention for classes, namespaces, and filenames during your coding is a great benefit to the organization, structure, and readability of your code. 1. Class naming specification:The class name is best to contain only letters, and in most cases the numbers are discouraged, unless you want to use them, do not underline,-and other non-alphabetic characters, for example: Mycompany.useful_util. Debug_toolbar does not encourage such naming MyCompany.util.Base64 acceptable namingThe class name is best included in the organization, in the appropriate namespace by using. To access the object properties, at a minimum, the class name should have a top-level package. For example: MyCompany.data.CoolProxy mycompany.application

The top-level package name and the actual class name should use the camelcased naming convention, and the others should be lowercase, as follows: MyCompany.form.action.AutoLoadDo not use Ext as the top-level package name, the first letter should follow the camelcased naming convention, such as: Ext.data.JsonProxy instead of Ext.data.JSONProxy MyCompany.util.HtmlParser instead of MyCompary.parser.HTMLParser MyCompany.server.Http instead of MyCompany.server.HTTP 2. Source file naming specification:The class name maps directly to the file path where the class is stored, so there can be only one class for each file, such as Ext.util.Observable is stored in path/to/src/Ext/util/Observable.js Ext.form.action.Submit is stored in path/to/src/Ext/form/action/Submit.js     MyCompany.chart.axis.Numeric is stored in path/to/src/MyCompany/chart/axis/Numeric.js    The PATH/TO/SRC directory contains all of the classes that are applied, and all classes should be placed under this common root directory, with the right namespaces for the best development, management, and deployment experience.  Methods and the naming conventions of variables are similar to class names, and the names of methods and variables contain only letters, and numbers are discouraged, unless they must be used, as well as without underscores-and other non-alphabetic characters. Methods and variable names should follow the camelcased naming convention and the first letter should apply. For example, an acceptable method name: EncodeUsingMd5 () replaces Getjsonresponse () with gethtml () instead of gethtml () with par Sexmlcontent () Alternative parsexmlcontent () acceptable variable name: var isgoodname var base64encoder var xmlReader var h Ttpserver 3. Attribute naming:Class Property name and UpperThe polygon method and the variable oneExcept when the property is a static constant. When a property is a static constant, the letter should be capitalized. Ext.MessageBox.YES = "Yes" Ext.MessageBox.YES = "Yes"     Ext.MessageBox.NO = "No"     MyCompany.alien.Math.PI = "4.13"     Second, define before ExtJS4, use Ext.extend to create the class, and after ExtJS4, use Ext.define to create the class.
Basic Syntax:Ext.define (ClassName, Members, onclasscreated);among them,ClassName: Class name member: This is an object that represents a collection of class members in the form of a key-value pair. Onclasscreated: This is a customizable callback function that calls this callback function when the class it depends on is ready, and the class itself will be completely created. This callback can be useful in a number of situations because of the class that creates a new asynchronous property. Cases:
1Ext.define (' Mycomponent.getwh ', {2Showsize:function(){3             varDom =Ext.get (Ext.getbody (). Dom);4Ext.Msg.alert (' My Component WH ', ' Dom Width: ' + dom.getwidth () + ' <br/>dom Height: ' +dom.getheight ());5     }6 });7Ext.onready (function(){8     varMypanel = ext.create (' Mycomponent.getwh '),{9 renderTo:Ext.getBody ()Ten     }); One mypanel.showsize (); A});

Effect:

   

the next goal is to customize the functionality of the components under various layouts in different requirements.

"ExtJS" About custom components

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.