According to experts, everything starts from API

Source: Internet
Author: User

 

Adapter extjs is compatible with other JS Development kits, such as jquery, prototype, and Yui, also, the directory docs Martial Arts secret, which is built by the integration of extjs air and Adobe AIR, provides some official extjs examples of examples, can be used to draw some source jsbuild source based on Huludao, there is a JSB project file, you can build your own Ext-all.jsresources extjs to run the required resource files, including icons and CSS these
1: liteserve is recommended here. The green software is small and functional. Of course you can also use Apache or IIS, and then point the web root directory to the extjs decompression directory, such as: D:/ext-2.0.2, port 80 to run. Then, input the address http: // localhost/docs/on the server. After loading, you can see the extjs API interface.
2: configuration, attributes, methods, and events. As shown in the figure above, the link to the four parts is provided at the top of the details: "properties" "methods" "events" "Config options ". The first column is a small arrow. This parameter description can be folded and expanded.


The second column is the parameter description. If there is still content not displayed in the description area, it will be displayed as "..." at the end of the content. For example, in animcollapse, the arrow in the first column can be expanded. The row of the activeitem parameter is the expanded result. The description of this parameter is displayed. Note that many parameters in config options have the default attribute, that is. When new is used, the parameter objects does not pass in this parameter. By default, this parameter uses the default value, which greatly reduces the number of construction parameters used. For example, in a new panel, you can configure only the HTML attributes except the rendered object, for example, new Ext. panel ({renderto: 'paneldiv ', HTML: 'content '});
Note that when you pass in the config object, do not add more or omit commas. The object Definition Format of IE is strict. The last member of an object cannot end with a comma. Otherwise, an error occurs during JS loading. Example: New Ext. panel ({renderto: 'paneldiv ', HTML: 'content',}); it can be passed in firefox3, but in IE6, it will lead to an error that cannot be compiled.

The third column is the definition class. Because Javascript is also the OO syntax, the subclass also inherits the attributes and methods of the parent class. The previous property or method with an up arrow is inherited. Generally, if you look at the special functions of a class (such as the method related to the collapse collapse of the Panel class ), you need to find difined by as the description line of the current class, which is very convenient.

For the use of config options, it is more convenient to specify the xtype of config options. When extjs generates the sub-object of the container, a new object is not needed, you only need to input the configuration object and specify the xtype in the object. Some containers use the default xtype for items. For example, the default xtype of the input configuration object of Ext. Panel is 'panel ', and the default xtype of the input configuration object of buttons of Ext. Panel is button. For example, the following three statements are equivalent:

New Ext. panel ({renderto: 'paneldiv ', items: [{HTML: 'content 1'}, {HTML: 'content 2'}], buttons: [{text: 'test button '}]}); you can also write it as new Ext. panel ({renderto: 'paneldiv ', items: [{xtype: 'panel', HTML: 'content 1'}, {xtype: 'panel ', HTML: 'content 2'}], buttons: [{xtype: 'button ', text: 'test button'}]}); or use the new method new Ext. panel ({renderto: 'paneldiv ', items: [New Ext. panel ({HTML: 'content 1'}), new Ext. panel ({HTML: 'content 2'})], buttons: [New Ext. button ({text: 'test button '})]});
Public properties, which defines the member variables of the object. It can be accessed directly by the dot. Generally, this part is read-only.
Note the initialconfig attribute. This is the case.

Initialconfig: Object
This component's initial configuration specification. Read-only.

This attribute can directly access your initialization object, which saves some var variables, for example, passing in the config object, such as toolbar. You can get it directly from the initialconfig attribute.
Public methods, that is, the public object method. This part defines the accessible methods of objects.
This section also describes the parameters of the method. For JavaScript, it is relatively "random" and does not support overload, making it very easy to make mistakes when writing parameters. Therefore, you need to pay attention to the parameter types. For different parameter types, the parameter types can be separated by a comma. For example, after the add method is expanded, you can see the detailed usage methods of each parameter. For example, the following describes the object parameters:
A component config object may be passed in order to avoid the overhead of constructing a real Component Object
That is to say, you can directly upload a Config object instead of an ext. Component Object. In this way, you can understand that it is also possible to use a method similar to add ({xtype: 'click', text: 'click.

Therefore, the extjs API is the most comprehensive extjs tutorial, which is better than any tutorial or practice. Of course, there is also a deeper learning part, that is, you have to look at the extjs source code, look at the extjs source code can achieve some more powerful functions than the API, for example, put the ext in formlayout. form. radio. This depends on the source code.

The next part is also very important. To increase the extjs object behavior, in addition to the extension object. The most common thing is to add listeners. You will often see some people writing listener on the internet, without knowing how to use those parameters. Here is the most worth learning. That is, the following:
Public Events

For example, the first line is active: (ext. panel P), that is to say, in the listeners of this object, you can listen to the active method. This method has a parameter P, and the input object is Ext. panel. Generally, if the input parameter name is the current class or its parent class, it refers to the object itself. For example, the name of the 2nd events is clear: ext. container this. But you don't need to name the variable this when using it. Why? The javascript keyword is simple.

The next line is the event occurrence condition: fires after the Panel has been exactly ally activated
This indicates that the event is triggered when the object becomes visible and active.


After reading the API documentation, do you know how to use the event? If you do not know, check the Code:

New Ext. panel ({renderto: 'paneldiv ', Title: 'title', items: [{xtype: 'button', text: 'button'}], listeners: {afterlayout: function (panel, layout) {alert (panel. getxtype ());}}});

Because Active is not a directly called event, you can use the afterlayout event as an example. You can try to use panel to access the method of your new object in the method after afterlayout. You will find that the free space provided by extjs is actually very powerful!

In addition to specifying listeners when creating an object, you can use the on method to dynamically add an object after it is created. API:
On (string eventname, function handler, [object scope], [object options])
If you do not want to listen, you can also remove it using UN:
UN (string eventname, function handler, [object scope])

Another point is worth noting. Although the component objects of extjs all contain DOM elements, there are also methods supported by DOM elements, such as click and resize. However, extjs events are extended. That is, some special methods supported by extjs may be added, and the behavior may be different from the direct Dom call, such as the resize method:
Resize: (ext. Component this, number adjwidth, number adjheight, number rawwidth, number rawheight)
The first element is an extjs object, which is significantly different from html dom elements.


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.