diff --git a/src/main/java/com/vaadin/flow/component/grid/Grid.java b/src/main/java/com/vaadin/flow/component/grid/Grid.java index 5008f029..b72c2f3e 100755 --- a/src/main/java/com/vaadin/flow/component/grid/Grid.java +++ b/src/main/java/com/vaadin/flow/component/grid/Grid.java @@ -109,6 +109,7 @@ @HtmlImport("frontend://bower_components/vaadin-checkbox/src/vaadin-checkbox.html") @HtmlImport("frontend://flow-component-renderer.html") @JavaScript("frontend://gridConnector.js") + public class Grid extends Component implements HasDataProvider, HasStyle, HasSize, Focusable>, SortNotifier, GridSortOrder>, HasTheme { diff --git a/src/test/java/com/vaadin/flow/component/grid/demo/GridView.java b/src/test/java/com/vaadin/flow/component/grid/demo/GridView.java index 78f1fa06..2eaae6cf 100644 --- a/src/test/java/com/vaadin/flow/component/grid/demo/GridView.java +++ b/src/test/java/com/vaadin/flow/component/grid/demo/GridView.java @@ -369,6 +369,7 @@ protected void initView() { createDisabledGrid(); createBasicTreeGridUsage(); createLazyLoadingTreeGridUsage(); + createGridWithStyling(); addCard("Grid example model", new Label("These objects are used in the examples above")); @@ -1082,6 +1083,21 @@ private void createDisabledGrid() { addCard("Disabled grid", grid, div); } + private void createGridWithStyling() { + // begin-source-example + // source-example-heading: Grid with styling + Grid grid = new Grid<>(); + List people = createItems(50); + grid.setItems(people); + + grid.addColumn(Person::getName).setHeader("Name"); + grid.addColumn(Person::getAge).setHeader("Age"); + grid.addThemeNames("no-border", "no-row-borders", "row-stripes"); + // end-source-example + grid.setId("basic-grid-with-style"); + addCard("Grid with styling", grid); + } + private Map> childMap; private void createBasicTreeGridUsage() { diff --git a/src/test/java/com/vaadin/flow/component/grid/it/GridViewIT.java b/src/test/java/com/vaadin/flow/component/grid/it/GridViewIT.java index d8e8901f..8ba763b8 100644 --- a/src/test/java/com/vaadin/flow/component/grid/it/GridViewIT.java +++ b/src/test/java/com/vaadin/flow/component/grid/it/GridViewIT.java @@ -676,6 +676,18 @@ public void disabledGrid_itemsAreDisabled() { button.isEnabled()); } + @Test + public void gridWithStyling_correctThemeAttribute() { + openTabAndCheckForErrors(""); + GridElement grid = $(GridElement.class).id("basic-grid-with-style"); + scrollToElement(grid); + waitUntil(driver -> grid.getAllColumns().size() == 2); + + Assert.assertEquals("Grid should have the correct theme attribute.", + grid.getAttribute("theme"), + "no-row-borders no-border row-stripes"); + } + private WebElement getCellContent(GridTHTDElement cell) { return (WebElement) executeScript( "return arguments[0].firstElementChild.assignedNodes()[0].firstElementChild;",