Example usage for com.google.gwt.dom.client TableSectionElement insertRow

List of usage examples for com.google.gwt.dom.client TableSectionElement insertRow

Introduction

In this page you can find the example usage for com.google.gwt.dom.client TableSectionElement insertRow.

Prototype

public final native TableRowElement insertRow(int index) ;

Source Link

Document

Insert a row into this section.

Usage

From source file:com.google.gwt.sample.contacts.client.view.ContactsViewImpl.java

public void setRowData(List<T> rowData) {
    this.rowData = rowData;

    TableElement table = Document.get().createTableElement();
    TableSectionElement tbody;
    table.appendChild(tbody = Document.get().createTBodyElement());

    for (int i = 0; i < rowData.size(); ++i) {
        TableRowElement row = tbody.insertRow(-1);
        T t = rowData.get(i);//w  w w  .j  a  v a 2s  .  co m

        for (int j = 0; j < columnDefinitions.size(); ++j) {
            TableCellElement cell = row.insertCell(-1);
            StringBuilder sb = new StringBuilder();
            columnDefinitions.get(j).render(t, sb);
            cell.setInnerHTML(sb.toString());

            // TODO: Really total hack! There's gotta be a better way...
            Element child = cell.getFirstChildElement();
            if (child != null) {
                Event.sinkEvents(child, Event.ONFOCUS | Event.ONBLUR);
            }
        }
    }

    contactsTable.setHTML(table.getInnerHTML());
}