Example usage for com.vaadin.ui Grid getHeaderRowCount

List of usage examples for com.vaadin.ui Grid getHeaderRowCount

Introduction

In this page you can find the example usage for com.vaadin.ui Grid getHeaderRowCount.

Prototype

public int getHeaderRowCount() 

Source Link

Document

Gets the number of rows in the header section.

Usage

From source file:com.haulmont.cuba.web.gui.components.WebDataGrid.java

License:Apache License

protected void initHeaderRows(Grid component) {
    for (int i = 0; i < component.getHeaderRowCount(); i++) {
        Grid.HeaderRow gridRow = component.getHeaderRow(i);
        addHeaderRowInternal(gridRow);/*w w w.j  av a 2s. c  o m*/
    }
}

From source file:com.ocs.dynamo.ui.composite.table.export.TableExportActionHandler.java

License:Apache License

/**
 * Export a grid - this is achieved by wrapping the data source from the grid in a table
 * /*from ww  w. j av  a2s . c o  m*/
 * @param grid
 */
public void exportFromGrid(Grid grid) {
    Table table = new Table();

    table.setContainerDataSource(grid.getContainerDataSource());

    // copy header captions from grid to table
    for (Column c : grid.getColumns()) {
        Object oid = c.getPropertyId();

        String caption = "";
        for (int i = 0; i < grid.getHeaderRowCount(); i++) {
            HeaderRow r = grid.getHeaderRow(i);

            if (caption.length() > 0) {
                caption += " ";
            }

            try {
                caption += r.getCell(oid).getText();
            } catch (Exception ex) {
                // if it is not text, then it is HTML (very ugly, but seems
                // to
                // be the only way)
                caption += r.getCell(oid).getHtml();
            }
        }
        // replace HTML line breaks by space
        if (caption != null) {
            caption = caption.replaceAll("<\\w+/>", " ");
        }

        table.setColumnHeader(c.getPropertyId(), caption);
    }
    handleAction(actionExport, table, null);
}