EXT contains several methods starting with get. These methods can be used to obtain the DOM in the document, obtain the components in the current document, and obtain the ext element. Pay attention to the difference in usage.
1
, Get
Method The get method is used to obtain an ext element, that is, the type is Ext. object of element, ext. the element class is ext's Dom encapsulation, which represents the DOM elements. You can create an element object for each Dom, and you can use methods on the Element Object to perform operations specified on the Dom, for example, the hide method can hide elements and the initdd method can make the specified Dom have the drag-and-drop feature. The get method is short for Ext. element. Get.
GetThere is only one parameter in the method. This parameter is a mixed parameter and can beDomNodeIDOrElementOrDomNode object. See the following example.Code:
Ext. onready (function (){
VaR E = new Ext. element ("hello ");
Alert (Ext. Get ("hello "));
Alert (Ext. Get (document. getelementbyid ("hello ")));
Alert (Ext. Get (e ));
});
The HTML page contains a div with the ID of hello. The Code is as follows:
<Div id = "hello"> tttt </div>
Ext. get ("hello"), ext. get (document. getelementbyid ("hello"), ext. get (E) and other three methods can get an ext element corresponding to the DOM node hello.
2
Getcmp
Method-obtain ext
Component. The getcmp method is used to obtain an ext component, that is, a component or its subclass object initialized on the page. The getcmp method is in short form of the Ext. componentmgr. Get method. The getcmp method has only one parameter, that is, the component ID. For example, the following code:
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 obtain the component whose ID is H2, and call its settitle method to set the title of the Panel.
3
, Getdom
Method-Get Dom
Node The getdom method can get the DOM nodes in the document. This method contains a parameter, which can be the ID of the DOM node, the DOM Node object, or the ext element (element) corresponding to the 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:
<Div id = "hello"> tttt </div>
In the above Code, ext. getdom ("hello"), ext. getdom (E), ext. getdom (E. DOM.
4
, Getbody
Method-get the document body
Element)
. This method is used to directly obtain the document and document. the extjs element corresponding to the DOM node "body" is essentially the document. the body object is encapsulated into an extjs Element Object and returned. This method does not contain any parameters. For example, the following code directly renders panel H to the body element of the document.
Ext. onready (function (){
VaR H = new Ext. Panel ({Title: "test", width: 300, height: 200 });
H. Render (ext. getbody ());
});
5
, Getdoc
Method-obtain and document
Corresponding ext
Element) The getdoc method essentially encapsulates the current HTML document object into an extjs Element Object and returns it without any parameters.