aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/src/main/java/com/vaadin/client/connectors/grid/ColumnConnector.java6
-rwxr-xr-xclient/src/main/java/com/vaadin/client/widgets/Grid.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridComponents.java10
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/GridComponentsTest.java9
4 files changed, 23 insertions, 4 deletions
diff --git a/client/src/main/java/com/vaadin/client/connectors/grid/ColumnConnector.java b/client/src/main/java/com/vaadin/client/connectors/grid/ColumnConnector.java
index c47488f78e..7ac6c518ad 100644
--- a/client/src/main/java/com/vaadin/client/connectors/grid/ColumnConnector.java
+++ b/client/src/main/java/com/vaadin/client/connectors/grid/ColumnConnector.java
@@ -20,6 +20,7 @@ import com.vaadin.client.annotations.OnStateChange;
import com.vaadin.client.connectors.AbstractRendererConnector;
import com.vaadin.client.extensions.AbstractExtensionConnector;
import com.vaadin.client.widgets.Grid.Column;
+import com.vaadin.client.widgets.Grid.HeaderCell;
import com.vaadin.shared.data.DataCommunicatorConstants;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.grid.ColumnState;
@@ -48,6 +49,11 @@ public class ColumnConnector extends AbstractExtensionConnector {
public String getConnectorId() {
return connectorId;
}
+
+ @Override
+ protected void setDefaultHeaderContent(HeaderCell cell) {
+ // NO-OP, Server takes care of header contents.
+ }
}
private CustomColumn column;
diff --git a/client/src/main/java/com/vaadin/client/widgets/Grid.java b/client/src/main/java/com/vaadin/client/widgets/Grid.java
index 45937e0c07..9a5674e86e 100755
--- a/client/src/main/java/com/vaadin/client/widgets/Grid.java
+++ b/client/src/main/java/com/vaadin/client/widgets/Grid.java
@@ -4853,7 +4853,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
private void updateHeader() {
HeaderRow row = grid.getHeader().getDefaultRow();
if (row != null) {
- row.getCell(this).setText(headerCaption);
+ setDefaultHeaderContent(row.getCell(this));
if (isHidable()) {
grid.columnHider.updateHidingToggle(this);
}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridComponents.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridComponents.java
index dce85d3be9..a48c8400c1 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/grid/GridComponents.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridComponents.java
@@ -25,7 +25,8 @@ public class GridComponents extends AbstractTestUIWithLog {
@Override
protected void setup(VaadinRequest request) {
Grid<String> grid = new Grid<>();
- grid.addColumn(string -> new Label(string), new ComponentRenderer());
+ grid.addColumn(string -> new Label(string), new ComponentRenderer())
+ .setCaption("Label");
grid.addComponentColumn(string -> {
if (textFields.containsKey(string)) {
log("Reusing old text field for: " + string);
@@ -41,7 +42,7 @@ public class GridComponents extends AbstractTestUIWithLog {
textFields.put(string, textField);
});
return textField;
- });
+ }).setId("textField").setCaption("TextField");
grid.addColumn(string -> {
Button button = new Button("Click Me!",
e -> Notification.show(
@@ -49,10 +50,13 @@ public class GridComponents extends AbstractTestUIWithLog {
Type.WARNING_MESSAGE));
button.setId(string.replace(' ', '_').toLowerCase());
return button;
- }, new ComponentRenderer());
+ }, new ComponentRenderer()).setId("button").setCaption("Button");
// make sure the buttons and focus outlines fit completely in a row
grid.setRowHeight(40);
+ grid.getDefaultHeaderRow().join("textField", "button")
+ .setText("Other Components");
+
addComponent(grid);
grid.setSizeFull();
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridComponentsTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridComponentsTest.java
index b74386e2d9..af985aad9a 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridComponentsTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridComponentsTest.java
@@ -82,6 +82,15 @@ public class GridComponentsTest extends MultiBrowserTest {
assertRowExists(999, "Row 999");
}
+ @Test
+ public void testHeaders() {
+ openTestURL();
+ GridElement grid = $(GridElement.class).first();
+ Assert.assertEquals("Label", grid.getHeaderCell(0, 0).getText());
+ Assert.assertEquals("Other Components",
+ grid.getHeaderCell(0, 1).getText());
+ }
+
private void assertRowExists(int i, String string) {
GridRowElement row = $(GridElement.class).first().getRow(i);
Assert.assertEquals("Label text did not match", string,