use of com.vaadin.flow.component.grid.HeaderRow.HeaderCell in project flow-components by vaadin.
the class HeaderFooterTest method joinTwoLastHeaderCells.
@Test
public void joinTwoLastHeaderCells() {
HeaderRow bottom = grid.prependHeaderRow();
HeaderRow top = grid.prependHeaderRow();
HeaderCell firstCell = top.getCells().get(0);
HeaderCell joined = top.join(secondColumn, thirdColumn);
List<List<Element>> layers = getColumnLayersAndAssertCount(2);
assertRowWrapsLayer(bottom, layers.get(0));
assertRowWrapsLayer(top, layers.get(1));
Assert.assertEquals("HeaderRow should have two cells after joining two of three cells", 2, top.getCells().size());
Assert.assertEquals("The joined cell should be the last cell of the row after joining two last cells", joined, top.getCells().get(1));
Assert.assertEquals("The first cell should not be affected after joining two last cells", firstCell, top.getCells().get(0));
}
use of com.vaadin.flow.component.grid.HeaderRow.HeaderCell in project flow-components by vaadin.
the class HeaderFooterTest method joinTwoFirstHeaderCellsOnLowerLayer_layerMovedToTop.
@Test
public void joinTwoFirstHeaderCellsOnLowerLayer_layerMovedToTop() {
grid.appendFooterRow();
grid.prependHeaderRow();
FooterRow footer = grid.appendFooterRow();
HeaderRow header = grid.prependHeaderRow();
HeaderCell lastCell = header.getCells().get(2);
List<List<Element>> layers = getColumnLayersAndAssertCount(3);
assertRowWrapsLayer(header, layers.get(1), 3);
assertRowWrapsLayer(footer, layers.get(2), 3);
header.join(firstColumn, secondColumn);
layers = getColumnLayersAndAssertCount(3);
assertRowWrapsLayer(footer, layers.get(1), 3);
assertRowWrapsLayer(header, layers.get(2), 2);
Assert.assertEquals("The last cell should not be affected after joining two first cells", lastCell, header.getCells().get(1));
}
use of com.vaadin.flow.component.grid.HeaderRow.HeaderCell in project flow-components by vaadin.
the class GridViewHeaderAndFooterRowsPage method createHeaderAndFooterUsingComponents.
private void createHeaderAndFooterUsingComponents() {
Grid<Person> grid = new Grid<>();
grid.setItems(getItems());
Column<Person> nameColumn = grid.addColumn(Person::getFirstName).setHeader(new Span("Name")).setComparator((p1, p2) -> p1.getFirstName().compareToIgnoreCase(p2.getFirstName()));
Column<Person> ageColumn = grid.addColumn(Person::getAge, "age").setHeader(new Span("Age"));
Column<Person> streetColumn = grid.addColumn(person -> person.getAddress().getStreet()).setHeader(new Span("Street"));
Column<Person> postalCodeColumn = grid.addColumn(person -> person.getAddress().getPostalCode()).setHeader(new Span("Postal Code"));
HeaderRow topRow = grid.prependHeaderRow();
HeaderCell informationCell = topRow.join(nameColumn, ageColumn);
informationCell.setComponent(new Span("Basic Information"));
HeaderCell addressCell = topRow.join(streetColumn, postalCodeColumn);
addressCell.setComponent(new Span("Address Information"));
grid.appendFooterRow().getCell(nameColumn).setComponent(new Span("Total: " + getItems().size() + " people"));
grid.setId("grid-header-with-components");
addCard("Header and footer rows", "Header and footer using components", grid);
}
Aggregations