ExtJS Frame Series The difference between get, GetDOM, getcmp, GetBody, Getdoc

Source: Internet
Author: User

The difference between get, GetDOM, getcmp, GetBody and Getdoc of ExtJS frame series
EXT, get
Methods and differences of acquisition elements (get) commonly used in ext
Ext has several methods that start with get, which can be used to obtain the DOM in the document, to get the components in the current document, to get the ext element, and so on, to be aware of the difference in use.
1, Get method
The Get method is used to obtain an EXT element, That is, an object of type Ext.element, the Ext.element class is the encapsulation of the DOM by EXT, which represents the elements of the DOM, and can create a corresponding element object for each DOM, which can be done by means of the method on the element object, such as using the Hide method to Hidden elements, INITDD methods allow the specified DOM to have drag-and-drop attributes, and so on. The Get method is actually a shorthand form for Ext.Element.get.
The Get method has only one parameter, which is a mixed parameter, either the ID of the DOM node, an element, or a DOM node object.
Look at the following sample code:
CODE:
Ext.onready (function () {

var e=new ext.element ("Hello");

Alert (Ext.get ("Hello"));

Alert (Ext.get ("Hello")) (document.getElementById);

Alert (Ext.get (e));

});

The HTML page contains a div with the id hello, and the code is as follows:

<div id= "Hello" >aaa</div>

Three methods, such as Ext.get ("Hello"), Ext.get (document.getElementById ("Hello")), Ext.get (e), and so on, can get an EXT element that corresponds to the DOM node hello.
2, the GETCMP method is used to obtain the EXT component.
The getcmp method is used to obtain an ext component, which is an object that has already been initialized in the page component or its subclasses, and getcmp method is in fact the shorthand form of the Ext.ComponentMgr.get method. There is only one parameter in the GETCMP method, which is the ID of the component.
Look at the following code:
CODE:
Ext.onready (function () {

var h=new ext.panel ({
ID: "H2",
Title: "",

Renderto: "Hello",
WIDTH:300,

height:200
});

EXT.GETCMP ("H2"). Settitle ("new title");

});

We use EXT.GETCMP ("H2"). To get the component with ID H2 and call its Settitle method to set the title of the panel
3, GetDOM Method-Get the DOM node
The GetDOM method can get a DOM node in a document that contains a parameter that can be the ID of a DOM node, a DOM node object, or an ext element (element) corresponding to a DOM node.
For example, the following code:

CODE:
Ext.onready (function () {

var e=new ext.element ("Hello");

Ext.getdom ("Hello");

Ext.getdom (e);

Ext.getdom (E.dom);

});

Html: Code

<div id= "Hello" >tttt</div>

In the above code, three statements, ext.getdom ("Hello"), Ext.getdom (E), Ext.getdom (E.dom), are returned by the same DOM node object.
4, GetBody Method-Get the document's body node elements (element).
This method directly obtains the EXTJS elements (element) corresponding to the DOM node in the document, in essence, the Document.body object is encapsulated into the ExtJS element object Document.body, and the method takes no parameters.
For example, the following code renders the panel h directly into the BODY element of the document.
CODE:
Ext.onready (function () {
var h=new ext.panel ({title: "Test", width:300,height:200});
H.render (Ext.getbody ());

});

5. Getdoc Method-Get the Ext element (element) corresponding to the document
Essentially, the Getdoc method returns the current HTML document object, which is the element object that encapsulates the document object into ExtJS, without any arguments.

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.