aboutsummaryrefslogtreecommitdiffstats
path: root/server/src
diff options
context:
space:
mode:
authorArtur <artur@vaadin.com>2017-03-22 16:12:31 +0200
committerPekka Hyvönen <pekka@vaadin.com>2017-03-22 16:12:31 +0200
commit52359708adb2033eab2765377d7bcba0b8a97b54 (patch)
treea6b77555dadf3733724b2d7b245441634392493f /server/src
parentd01a6ef0271f5238ffcd0f986a30fc0d68102f72 (diff)
downloadvaadin-framework-52359708adb2033eab2765377d7bcba0b8a97b54.tar.gz
vaadin-framework-52359708adb2033eab2765377d7bcba0b8a97b54.zip
Set column captions when reading grid from a design file (#8770)
Fixes #8752
Diffstat (limited to 'server/src')
-rw-r--r--server/src/main/java/com/vaadin/ui/Grid.java12
-rw-r--r--server/src/test/java/com/vaadin/tests/server/component/grid/GridDeclarativeTest.java6
2 files changed, 14 insertions, 4 deletions
diff --git a/server/src/main/java/com/vaadin/ui/Grid.java b/server/src/main/java/com/vaadin/ui/Grid.java
index 733d6b8fcc..6b1d5bcb79 100644
--- a/server/src/main/java/com/vaadin/ui/Grid.java
+++ b/server/src/main/java/com/vaadin/ui/Grid.java
@@ -87,6 +87,7 @@ import com.vaadin.shared.ui.grid.GridConstants;
import com.vaadin.shared.ui.grid.GridConstants.Section;
import com.vaadin.shared.ui.grid.GridServerRpc;
import com.vaadin.shared.ui.grid.GridState;
+import com.vaadin.shared.ui.grid.GridStaticCellType;
import com.vaadin.shared.ui.grid.HeightMode;
import com.vaadin.shared.ui.grid.ScrollDestination;
import com.vaadin.shared.ui.grid.SectionState;
@@ -102,6 +103,7 @@ import com.vaadin.ui.components.grid.FooterRow;
import com.vaadin.ui.components.grid.GridSelectionModel;
import com.vaadin.ui.components.grid.Header;
import com.vaadin.ui.components.grid.Header.Row;
+import com.vaadin.ui.components.grid.HeaderCell;
import com.vaadin.ui.components.grid.HeaderRow;
import com.vaadin.ui.components.grid.ItemClickListener;
import com.vaadin.ui.components.grid.MultiSelectionModel;
@@ -3892,6 +3894,16 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
getFooter().readDesign(child, context);
}
}
+
+ // Sync default header captions to column captions
+ if (getDefaultHeaderRow() != null) {
+ for (Column<T, ?> c : getColumns()) {
+ HeaderCell headerCell = getDefaultHeaderRow().getCell(c);
+ if (headerCell.getCellType() == GridStaticCellType.TEXT) {
+ c.setCaption(headerCell.getText());
+ }
+ }
+ }
}
protected void readData(Element body,
diff --git a/server/src/test/java/com/vaadin/tests/server/component/grid/GridDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/grid/GridDeclarativeTest.java
index a905b1d900..52af306ec5 100644
--- a/server/src/test/java/com/vaadin/tests/server/component/grid/GridDeclarativeTest.java
+++ b/server/src/test/java/com/vaadin/tests/server/component/grid/GridDeclarativeTest.java
@@ -802,11 +802,9 @@ public class GridDeclarativeTest extends AbstractListingDeclarativeTest<Grid> {
// Property mapping
Assert.assertEquals(expectedColumn.getId(), column.getId());
- // Not tested because of
- // https://github.com/vaadin/framework/issues/8752
// Header caption
- // Assert.assertEquals(expectedColumn.getCaption(),
- // column.getCaption());
+ Assert.assertEquals(expectedColumn.getCaption(),
+ column.getCaption());
// Value providers are not stored in the declarative file
// so this only works for bean properties