dfilkovi
dfilkovi

Reputation: 3091

Extjs dom and Ext.Element creation problem

I create elements with Ext.element like this:

var table = new Ext.Element(document.createElement('table'));

    for(n=0;n<5;n++)
    {
        row = new Ext.Element(document.createElement('tr'));
        for(x=0;x<4;x++)
        {
            col = new Ext.Element(document.createElement('td'));
            col.update('cell text '+x);    
            row.appendChild(col);
        }
        table.appendChild(row);
    }

    Ext.fly('data').replaceWith(table);

This works i FF but not in IE, why is that?

Upvotes: 4

Views: 7297

Answers (3)

Sariq Shaikh
Sariq Shaikh

Reputation: 1124

This is a old post but for those who are still looking for answers, please check below code it should work fine in IE.

var table = new Ext.Element(document.createElement('table'));
var tbody = new Ext.Element(document.createElement('tbody'));
for(n=0;n<5;n++)
{
    var row = new Ext.Element(document.createElement('tr'));
    for(x=0;x<4;x++)
    {
        var col = new Ext.Element(document.createElement('td'));
        col.update('cell text '+x);    
        row.appendChild(col);
    }
    tbody.appendChild(row);
}
table.appendChild(tbody);

Ext.fly('data').replaceWith(table);

Upvotes: 0

Swar
Swar

Reputation: 5503

Try to use Ext.DomHelper for creating DOM elements and working with them. Have a look at the DomHelper at Ext API Documentation and follow this tutorial.

Upvotes: 1

sra
sra

Reputation: 23983

The following code worked in IE8 with ExtJS 3.3

var table = new Ext.Element(document.createElement('table'));

for(n=0;n<5;n++)
{
    var row = new Ext.Element(document.createElement('tr'));
    for(x=0;x<4;x++)
    {
        var col = new Ext.Element(document.createElement('td'));
        col.update('cell text '+x);    
        row.appendChild(col);
    }
    table.appendChild(row);
}

Ext.fly('data').replaceWith(table);

Upvotes: 1

Related Questions