ExtJS - How to get DOM ID of a component?

倾然丶 夕夏残阳落幕 提交于 2020-01-05 08:26:09

问题


Say the component doesnt have an ID given to it. So how would you first, get a handle on the component, and then get the DOM Id of that component?

thanks in advance!

-Jack


回答1:


Use the javascript console. You can also install FireBug.

In your javascript code put:

 console.log(myComponentWhosIdIWantToGet);

Explore you object's properties.




回答2:


I believe this is what you need: http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.Component-method-getEl

Example:

//get Dom Element
var DomEl = Ext.getCmp('ComponentID').getEl();
//get Id
var DomElId = DomEl.id;



回答3:


You can use this (not so many distinctions from answer of Meister but anyway):

var DomEl = Ext.getCmp('ComponentID').getEl().dom.id;


来源:https://stackoverflow.com/questions/20253834/extjs-how-to-get-dom-id-of-a-component

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!