aboutsummaryrefslogtreecommitdiffstats
path: root/client/src
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2016-09-06 15:07:37 +0300
committerArtur Signell <artur@vaadin.com>2016-09-08 11:33:14 +0000
commit74df0fadeb7d6c2a6e15b4716602d6ab7ffb54b1 (patch)
tree8d913860bc0e2fb9b14dafcf8cff149e641aea1a /client/src
parent8a4d90789ffd6a28ce29870bd176ace62f33288f (diff)
downloadvaadin-framework-74df0fadeb7d6c2a6e15b4716602d6ab7ffb54b1.tar.gz
vaadin-framework-74df0fadeb7d6c2a6e15b4716602d6ab7ffb54b1.zip
Add StyleGenerators for Grid and Columns
Change-Id: I5eedce6ac24381d657357ff07ca1ccedd804158d
Diffstat (limited to 'client/src')
-rw-r--r--client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java23
1 files changed, 23 insertions, 0 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 ab0f6037f1..880de07d55 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
@@ -76,6 +76,29 @@ public class GridConnector
// Default selection style is space key.
spaceSelectHandler = new SpaceSelectHandler<JsonObject>(getWidget());
getWidget().addSortHandler(this::handleSortEvent);
+ getWidget().setRowStyleGenerator(rowRef -> {
+ JsonObject json = rowRef.getRow();
+ return json.hasKey(GridState.JSONKEY_ROWSTYLE)
+ ? json.getString(GridState.JSONKEY_ROWSTYLE) : null;
+ });
+ getWidget().setCellStyleGenerator(cellRef -> {
+ JsonObject row = cellRef.getRow();
+ if (!row.hasKey(GridState.JSONKEY_CELLSTYLES)) {
+ return null;
+ }
+
+ Column<?, JsonObject> column = cellRef.getColumn();
+ if (columnToIdMap.containsKey(column)) {
+ String id = columnToIdMap.get(column);
+ JsonObject cellStyles = row
+ .getObject(GridState.JSONKEY_CELLSTYLES);
+ if (cellStyles.hasKey(id)) {
+ return cellStyles.getString(id);
+ }
+ }
+
+ return null;
+ });
layout();
}