PDA

View Full Version : How to get html element contet from a panel?



reddy479
4 Oct 2012, 9:42 PM
Hi guys ,
This is Ranjihtreddy.
I am not able to get content which is html of panel by panel id.


var item5 = Ext.create('Ext.Panel', {
id: 'panel1',
html: '<div ><p> I want to get this content.</p></div>',
});

I am trying to get this content so that i can append this content in html editor.
i know how to update the content of panel but i don't know how retrieve this html content of panel.

Could you please help me out.

Thanks in advance.

Ranjithreddy Abbareddy

skirtle
5 Oct 2012, 4:09 AM
Please post questions in the relevant forum. I've moved your thread to the ExtJS 4 Q&A forum.

It's not exactly clear what you're trying to do. If you want to grab the HTML paragraph element you'll need to do something like this:


var element = item5.el.down('p');

The down method is just one of the many method for navigating the DOM. Others include child, query, select and first. See the docs for more:

http://docs.sencha.com/ext-js/4-1/#!/api/Ext.dom.Element-method-select

If you just want all the content in the panel's body then that's:


item5.body.dom.innerHTML

vasanth.kvj
6 Oct 2012, 7:20 AM
Reddy, when you have id then you can play in and around with Extjs. There are lot of ways available to get the content of panel using id. They are,


Ext.ComponentQuery.query('#panel1')[0].getEl().dom.textContent;
Ext.get('panel1').dom.textContent;
Ext.getCmp('panel1').getEl().dom.textContent;
Ext.select('#panel1').elements[0].textContent;

All will give you the same result but varies in traversing - Dom manipulations.

reddy479
9 Oct 2012, 11:57 PM
Thanks for the reply.
It helped me .