PDA

View Full Version : How to create Ext Element from javascript variable



rajneesh103
6 Aug 2007, 8:29 PM
Can anybody tell me how to create Ext Element from javascript variable?

I have the following code:

var htl = '<div name="OutEditGridContainer" id="OutEditGridContainer"><div id="EditGridContainer"><table name="tblT2PO_DOC_VEND_1" id="tblT2PO_DOC_VEND_1" class="ADVGrid"><thead><tr class="ADVGridHdr"><th style="width:13px;"><span></span></th></tr></thead></table></div></div>';

var newdiv = document.createElement('div');
newdiv.setAttribute('id','mydiv');
newdiv.innerHTML = htl;

var a = new Ext.Element(newdiv);
var b = a.query("div div table thead");
alert(b[0]);

I want to get a handle to thead so that I can add a new <tr> there?

tryanDLS
7 Aug 2007, 8:27 AM
Use DomHelper to append elements


var el = Ext.DomHelper.append(document.body, {tag:'div', id:'myId'}, true);
el.update(htl);