use of com.vaadin.flow.component.grid.HeaderRow.HeaderCell in project flow-components by vaadin.
the class HeaderFooterTest method getJoinedCellByColumn_worksWithEachChildColumn.
@Test
public void getJoinedCellByColumn_worksWithEachChildColumn() {
grid.prependHeaderRow();
HeaderRow topRow = grid.prependHeaderRow();
HeaderCell joined = topRow.join(secondColumn, thirdColumn);
Assert.assertSame("Joined header cell was not found by its child column", joined, topRow.getCell(secondColumn));
Assert.assertSame("Joined header cell was not found by its child column", joined, topRow.getCell(thirdColumn));
Assert.assertSame("getCell(Column) returned unexpected cell after joining other cells", topRow.getCells().get(0), topRow.getCell(firstColumn));
}
use of com.vaadin.flow.component.grid.HeaderRow.HeaderCell in project flow-components by vaadin.
the class HeaderFooterTest method joinTwoLastHeaderCellsOnLowerLayer_layerMovedToTop.
@Test
public void joinTwoLastHeaderCellsOnLowerLayer_layerMovedToTop() {
grid.appendFooterRow();
grid.prependHeaderRow();
FooterRow footer = grid.appendFooterRow();
HeaderRow header = grid.prependHeaderRow();
HeaderCell firstCell = header.getCells().get(0);
List<List<Element>> layers = getColumnLayersAndAssertCount(3);
assertRowWrapsLayer(header, layers.get(1), 3);
assertRowWrapsLayer(footer, layers.get(2), 3);
header.join(secondColumn, thirdColumn);
layers = getColumnLayersAndAssertCount(3);
assertRowWrapsLayer(footer, layers.get(1), 3);
assertRowWrapsLayer(header, layers.get(2), 2);
Assert.assertEquals("The first cell should not be affected after joining two last cells", firstCell, header.getCells().get(0));
}
use of com.vaadin.flow.component.grid.HeaderRow.HeaderCell in project flow-components by vaadin.
the class HeaderFooterTest method joinTwoFirstHeaderCells.
@Test
public void joinTwoFirstHeaderCells() {
HeaderRow bottom = grid.prependHeaderRow();
HeaderRow top = grid.prependHeaderRow();
HeaderCell lastCell = top.getCells().get(2);
HeaderCell joined = top.join(firstColumn, secondColumn);
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 first cell of the row after joining two first cells", joined, top.getCells().get(0));
Assert.assertEquals("The last cell should not be affected after joining two first cells", lastCell, top.getCells().get(1));
}
use of com.vaadin.flow.component.grid.HeaderRow.HeaderCell in project flow-components by vaadin.
the class HeaderFooterTest method addHeader_joinCells_removeColumn_joinedCellRemains.
@Test
public void addHeader_joinCells_removeColumn_joinedCellRemains() {
HeaderRow bottomHeader = grid.prependHeaderRow();
HeaderRow topHeader = grid.prependHeaderRow();
HeaderCell joinedCell = topHeader.join(firstColumn, secondColumn);
Assert.assertEquals("Top row should have two cells after joining two of three", 2, topHeader.getCells().size());
grid.removeColumn(secondColumn);
Assert.assertEquals("The joined header cell should remain when only one of the child columns is removed", 2, topHeader.getCells().size());
Assert.assertSame("The joined cell should still be linked to the remaining child column, " + "after removing the other child column", joinedCell, topHeader.getCell(firstColumn));
List<List<Element>> layers = getColumnLayersAndAssertCount(2);
assertRowWrapsLayer(bottomHeader, layers.get(0));
assertRowWrapsLayer(topHeader, layers.get(1));
}
use of com.vaadin.flow.component.grid.HeaderRow.HeaderCell in project flow-components by vaadin.
the class GridViewHeaderAndFooterRowsPage method createGridWithHeaderAndFooterRows.
private void createGridWithHeaderAndFooterRows() {
Grid<Person> grid = new Grid<>();
grid.setItems(createItems());
Column<Person> nameColumn = grid.addColumn(Person::getFirstName).setHeader("Name").setComparator((p1, p2) -> p1.getFirstName().compareToIgnoreCase(p2.getFirstName()));
Column<Person> ageColumn = grid.addColumn(Person::getAge, "age").setHeader("Age");
Column<Person> streetColumn = grid.addColumn(person -> person.getAddress().getStreet()).setHeader("Street");
Column<Person> postalCodeColumn = grid.addColumn(person -> person.getAddress().getPostalCode()).setHeader("Postal Code");
HeaderRow topRow = grid.prependHeaderRow();
HeaderCell informationCell = topRow.join(nameColumn, ageColumn);
informationCell.setText("Basic Information");
HeaderCell addressCell = topRow.join(streetColumn, postalCodeColumn);
addressCell.setText("Address Information");
grid.appendFooterRow().getCell(nameColumn).setText("Total: " + getItems().size() + " people");
grid.setId("grid-with-header-and-footer-rows");
addCard("Header and footer rows", "Adding header and footer rows", grid);
}
Aggregations