The difference between get, GetDOM, getcmp, GetBody, Getdoc in ext

Source: Internet
Author: User

Ext contains several methods that begin 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 gets method is used to obtain an EXT element, namely type is Ext.element object, The Ext.element class is an ext-dom wrapper that represents the elements of the DOM and can create a corresponding element object for each DOM, using the methods on the element object to implement the actions specified by the DOM, such as hiding the elements with the Hide method, The INITDD method allows 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:

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>

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 , getcmp Method-Get Ext components. 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. For example, the following code:
Ext.onready (function () {var h=new ext.panel ({ID: "H2", Title: "", Renderto: "Hello", width:30       0, height:200});       EXT.GETCMP ("H2"). Settitle ("new title"); });

Ext.onready (function () {

var h=new ext.panel ({

ID: "H2",

title: "",

Renderto: "Hello",

width:300 ,

height:200});

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

In the code, we use EXT.GETCMP ("H2") to get the component with the ID H2 and call its Settitle method to set the title of the panel. 3 , GetDOM Method-Get Dom nodeThe 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:
Ext.onready (function () {var e=new ext.element ("Hello");       Ext.getdom ("Hello");       Ext.getdom (e);       Ext.getdom (E.dom);       }); Html: <divid= "Hello" >Tttt </div>
Ext.onready (function () {

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

Ext.getdom ("Hello");

Ext.getdom (e);

Ext.getdom (e.dom);

});

Html:

<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 body of the document 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.
Ext.onready (function () {var h=new ext.panel ({title: "Test", width:300,height:200});       H.render (Ext.getbody ()); });
Ext.onready (function () {

var h=new ext.panel ({title: "Test", width:300,height:200});

H.render (Ext.getbody ());

5 , Getdoc method-Get with document the corresponding ext elements (Element)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.