summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorAleksi Hietanen <aleksi@vaadin.com>2016-10-17 10:13:33 +0300
committerAleksi Hietanen <aleksi@vaadin.com>2016-10-25 14:38:11 +0300
commite0fcd1cfe0cea7dac124df0d86bf74f8d8c4f9be (patch)
tree826e734991743aa7531f026f74eb2f830715f247 /client
parent63d218efc0ee5825633b4950e3355f4e8cc7bc29 (diff)
downloadvaadin-framework-e0fcd1cfe0cea7dac124df0d86bf74f8d8c4f9be.tar.gz
vaadin-framework-e0fcd1cfe0cea7dac124df0d86bf74f8d8c4f9be.zip
Grid html/component content in headers
Change-Id: Ie6129b51d15d4f30a6b4c034999ff02deec1c6a7
Diffstat (limited to 'client')
-rw-r--r--client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java35
1 files changed, 32 insertions, 3 deletions
diff --git a/client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java b/client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java
index a19c955fc4..ad5f8200ea 100644
--- a/client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java
+++ b/client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java
@@ -54,6 +54,7 @@ import com.vaadin.client.widget.grid.sort.SortOrder;
import com.vaadin.client.widgets.Grid;
import com.vaadin.client.widgets.Grid.Column;
import com.vaadin.client.widgets.Grid.FooterRow;
+import com.vaadin.client.widgets.Grid.HeaderCell;
import com.vaadin.client.widgets.Grid.HeaderRow;
import com.vaadin.shared.MouseEventDetails;
import com.vaadin.shared.data.DataCommunicatorConstants;
@@ -66,6 +67,7 @@ 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.SectionState;
+import com.vaadin.shared.ui.grid.SectionState.CellState;
import com.vaadin.shared.ui.grid.SectionState.RowState;
import elemental.json.JsonObject;
@@ -255,14 +257,41 @@ public class GridConnector
for (RowState rowState : state.rows) {
HeaderRow row = grid.appendHeaderRow();
+ if (rowState.defaultHeader) {
+ grid.setDefaultHeaderRow(row);
+ }
+
rowState.cells.forEach((columnId, cellState) -> {
- row.getCell(getColumn(columnId)).setText(cellState.text);
+ updateHeaderCellFromState(row.getCell(getColumn(columnId)),
+ cellState);
});
+ }
+ }
- if (rowState.defaultHeader) {
- grid.setDefaultHeaderRow(row);
+ private void updateHeaderCellFromState(HeaderCell cell,
+ CellState cellState) {
+ switch (cellState.type) {
+ case TEXT:
+ cell.setText(cellState.text);
+ break;
+ case HTML:
+ cell.setHtml(cellState.html);
+ break;
+ case WIDGET:
+ ComponentConnector connector = (ComponentConnector) cellState.connector;
+ if (connector != null) {
+ cell.setWidget(connector.getWidget());
+ } else {
+ // This happens if you do setVisible(false) on the component on
+ // the server side
+ cell.setWidget(null);
}
+ break;
+ default:
+ throw new IllegalStateException(
+ "unexpected cell type: " + cellState.type);
}
+ cell.setStyleName(cellState.styleName);
}
/**