Example usage for com.vaadin.ui.components.grid HeaderCell setStyleName

List of usage examples for com.vaadin.ui.components.grid HeaderCell setStyleName

Introduction

In this page you can find the example usage for com.vaadin.ui.components.grid HeaderCell setStyleName.

Prototype

public void setStyleName(String styleName);

Source Link

Document

Sets a custom style name for this cell.

Usage

From source file:org.jpos.qi.minigl.AccountsView.java

License:Open Source License

public void formatEntriesGrid() {
    String pattern = getApp().getMessage("datetime");
    SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
    entryGrid.getColumn("account").setHidden(true);
    entryGrid.addColumn(glEntry -> glEntry.getTransaction().getTimestamp()).setId("timestamp")
            .setRenderer(new DateRenderer(dateFormat)).setCaption(getCaptionFromId("timestamp"))
            .setSortable(true).setHidable(false);
    entryGrid.addColumn(GLEntry::getBalance).setId("balance").setRenderer(createAmountRenderer())
            .setStyleGenerator(cellStyle -> "align-right").setCaption(getCaptionFromId("balance"))
            .setSortable(true).setHidable(false);
    entryGrid.sort("timestamp");
    entryGrid.setColumnOrder("timestamp", "detail", "tags", "layer", "debit", "credit", "balance");
    entryGrid.setHeightByRows(10);/*from w  ww.  ja  v  a  2 s  .  co m*/

    //HEADER
    entryGrid.getDefaultHeaderRow().getCell("balance").setStyleName("align-right");
    HeaderRow initialBalanceHeader = entryGrid.appendHeaderRow();
    HeaderCell label = initialBalanceHeader.join("timestamp", "detail", "tags", "layer", "credit", "debit");
    label.setText("Initial Balance");
    HeaderCell value = initialBalanceHeader.getCell("balance");
    value.setStyleName("amount-header");

    //FOOTER
    FooterRow footer = entryGrid.appendFooterRow();
    FooterCell totalCell = footer.join("timestamp", "detail", "tags", "layer");
    totalCell.setHtml("<strong>TOTAL</strong>");
    FooterCell debitTotal = footer.getCell("debit");
    debitTotal.setStyleName("align-right");
    FooterCell creditTotal = footer.getCell("credit");
    creditTotal.setStyleName("align-right");
    FooterCell balanceTotal = footer.getCell("balance");
    balanceTotal.setStyleName("align-right");
}