Example usage for com.vaadin.ui Grid getHeaderRow

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

Introduction

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

Prototype

public HeaderRow getHeaderRow(int index) 

Source Link

Document

Returns the header row at the given index.

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);/*from  w  w w .  ja v  a  2 s .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 w  ww.jav a 2s . 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);
}

From source file:org.vaadin.gridfiledownloadertest.GridFileDownloaderUI.java

License:Apache License

@SuppressWarnings("unchecked")
@Override//from w ww . j a  va2s  .  c o m
protected void init(VaadinRequest request) {
    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    setContent(layout);

    final Grid grid = new Grid("Attachment grid");
    grid.setHeightMode(HeightMode.ROW);
    grid.setHeightByRows(5);
    grid.setSelectionMode(SelectionMode.NONE);

    Column column = grid.addColumn("filename");
    column.setHeaderCaption("File name");
    column.setExpandRatio(1);

    Indexed dataSource = grid.getContainerDataSource();
    for (int i = 1; i <= 5; ++i) {
        DownloadPojo cp = new DownloadPojo(i);
        Item item = dataSource.addItem(cp);
        item.getItemProperty("filename").setValue(cp.getName());
    }
    layout.addComponent(grid);
    addGridFileDownloader(grid);

    // set tooltip for the default download column
    grid.setCellDescriptionGenerator(new CellDescriptionGenerator() {

        @Override
        public String getDescription(CellReference cell) {
            if (FontAwesome.DOWNLOAD.equals(cell.getPropertyId())) {
                return "download";
            }
            return null;
        }
    });

    // clear the header
    HeaderCell downloadHeader = grid.getHeaderRow(0).getCell(FontAwesome.DOWNLOAD);
    downloadHeader.setHtml("");
}