tags:

views:

201

answers:

1

To build a HTML table I use direct DOM instead of a predefined Widget to set thead and tbody. But when I insert a cell with the insertCell() method GWT inserts an td element but should insert an th element.

So

TableElement table = Document.get().createTableElement();
TableSectionElement thead = table.createTHead();
TableRowElement headRow = thead.insertRow(-1);
headRow.insertCell(-1).setInnerText( "header1" );

gives

table/thead/tr/td

but should give

table/thead/tr/th

Any idea how to solve this problem? Use the "old-school" DOM.createXXX()-Methods?

A: 

you may create and add manually:

final TableCellElement th = Document.get().createTHElement();
th.setInnerText("i'm th!");
headRow.appendChild(th);

and you get:

<table><thead><tr><td>header1</td><th>i'm th!</th></tr></thead></table>
zmila