aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorAnna Koskinen <Ansku@users.noreply.github.com>2021-02-26 15:49:47 +0200
committerGitHub <noreply@github.com>2021-02-26 15:49:47 +0200
commitd336bfa5bf20b8187f498a9f41c04d706bbe2a28 (patch)
tree509c4bd77394a71dfa810ba40b3157538cd1fc55 /server
parent551177326f6ae8c4ddd7d5b3ab3bb3311304cc0a (diff)
downloadvaadin-framework-d336bfa5bf20b8187f498a9f41c04d706bbe2a28.tar.gz
vaadin-framework-d336bfa5bf20b8187f498a9f41c04d706bbe2a28.zip
Merged column headers should work within declarative Grid. (#12206)
- null check to prevent NPE from the merged column headers - convert to internal columnIds for merge handling - use correct cell in merge handling - switch away from streams in merge handling for easier readability - regression test Fixes: #10464
Diffstat (limited to 'server')
-rw-r--r--server/src/main/java/com/vaadin/ui/Grid.java3
-rw-r--r--server/src/main/java/com/vaadin/ui/components/grid/StaticSection.java22
2 files changed, 15 insertions, 10 deletions
diff --git a/server/src/main/java/com/vaadin/ui/Grid.java b/server/src/main/java/com/vaadin/ui/Grid.java
index 5d7534ae6a..dbde93b558 100644
--- a/server/src/main/java/com/vaadin/ui/Grid.java
+++ b/server/src/main/java/com/vaadin/ui/Grid.java
@@ -4762,7 +4762,8 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
for (Column<T, ?> c : getColumns()) {
HeaderCell headerCell = getDefaultHeaderRow().getCell(c);
if (headerCell.getCellType() == GridStaticCellType.TEXT) {
- c.setCaption(headerCell.getText());
+ String text = headerCell.getText();
+ c.setCaption(text == null ? "" : text);
}
}
}
diff --git a/server/src/main/java/com/vaadin/ui/components/grid/StaticSection.java b/server/src/main/java/com/vaadin/ui/components/grid/StaticSection.java
index 29af8bfc6c..96e374253a 100644
--- a/server/src/main/java/com/vaadin/ui/components/grid/StaticSection.java
+++ b/server/src/main/java/com/vaadin/ui/components/grid/StaticSection.java
@@ -290,18 +290,22 @@ public abstract class StaticSection<ROW extends StaticSection.StaticRow<?>>
+ columnIdsString + "'");
}
- Stream.of(columnIds).forEach(this::addCell);
-
- Stream<String> idsStream = Stream.of(columnIds);
+ CELL cell;
if (colspan > 1) {
- CELL newCell = createCell();
- addMergedCell(createCell(),
- idsStream.collect(Collectors.toSet()));
- newCell.readDesign(element, designContext);
+ Set<String> columnGroup = new HashSet<>();
+ for (String columnId : columnIds) {
+ addCell(columnId);
+ // convert the public columnIds into internal columnIds
+ columnGroup.add(getCell(columnId).getColumnId());
+ }
+ cell = createCell();
+ addMergedCell(cell, columnGroup);
} else {
- idsStream.map(this::getCell).forEach(
- cell -> cell.readDesign(element, designContext));
+ String columnId = columnIds[0];
+ addCell(columnId);
+ cell = getCell(columnId);
}
+ cell.readDesign(element, designContext);
}
}