Extjs Element

extjs

http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.dom.Element

How to hide or show elements?

Ext.select('selector string').enableDisplayMode().hide();
Ext.select('selector string').enableDisplayMode().show();

Ext.get('iBodyWait').enableDisplayMode().hide();

How can we add or remove CSS class to an element?

Ext.get(Ext.query('#descriptionNote')).addCls('error');

How to create a child element and append it to an existing element?

var child = col.el.createChild({html: '<div class="col-header-filter"></div>'});
col.el.appendChild(child);

How to update the content of an element?

Ext.get(document.body).update('<div id="test"></div>');

How to highlight an element?

Ext.get('myId').highlight();

How to obtain the raw DOM node / element?

var domEl = Ext.get('myDiv').dom;

How to obtain the DOM ID of an element?

var domID = Ext.get('myDiv').id;

How to retrieve the body element as an Ext.Element?

Ext.getBody();

What is the equivalent of document.getElementById?

Ext.getDom(id);

How to query the DOM using tag name, CSS selectors, and XPath?, and how to iterate over the result set?

// query by tag name
var nodes = Ext.query('div');
var nodes = Ext.query('div');
Ext.each(nodes, function (item, index, allItems) {
   document.write(index + '<br/>');
});

How to obtain an ExtJS Element given a DOM ID?

var myDiv = Ext.get('myId');

The .get() method provides internal caching, so multiple calls to retrieve the same object are incredibly fast.

What are some of the common things that can be done with a DOM element using ExtJS?

myDiv.highlight();
myDiv.addClass('red');
myDiv.center();
myDiv.setOpacity(.25);
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License