PDA

View Full Version : How to set html to a element in extjs



venkateshwar
6 Feb 2013, 11:48 PM
1) How to set `HTML` to already created panel or any other Element?


I am a beginner. I tried the below to set some content inside the HTML



var clickedElement = Ext.getCmp('id').el.child('>');
clickedElement.setHTML("hello");


The above is working fine but the problem is that as the panel has many div's inside it.. the above approach is erasing those inside html (i.e div's).


I saw through Chrome that the panel has three nested div's. So, if I want to add HTML to it then I need to give something like below:



var clickedElement = Ext.getCmp('id').el.child('>').child('>'); //two times child


When I tried the above approach, I am successfully adding the html content and also the div's doesn't remove. Here the problem is that, I can't see the added content (maybe because of some default stylings, I can see the content is being added in Chrome console though.)


I am just asking whether there is any efficient way of adding HTML to the panel. In my opinion, this should be very easy approach which I am complexing here.


2) How to check whether a Element has a particular child ?


Suppose, for example, If I add a extjs Button as a child into my panel while creating it. (which I can do). How to check whether the panel has the particular element (i.e button here)?


Before asking here, I searched alot and found somewhat relative but not helpful link (http://stackoverflow.com/q/13608736/1577396) to my problem.

sriram139
7 Feb 2013, 12:32 PM
1) Try: http://docs.sencha.com/ext-js/4-1/#!/api/Ext.panel.Panel-cfg-html
2) From panel:
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.panel.Panel-method-isAncestor
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.panel.Panel-method-child
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.panel.Panel-method-down

From button:
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.button.Button-method-isDescendantOf
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.button.Button-method-up
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.button.Button-method-findParentByType
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.button.Button-method-findParentBy

venkateshwar
7 Feb 2013, 9:04 PM
Thanks for these links. I will go through them.