summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Paul <henrik@vaadin.com>2014-11-20 12:46:01 +0200
committerVaadin Code Review <review@vaadin.com>2014-11-21 14:36:30 +0000
commit7d4e5cb0a98fbc3c397c6c74385210e4ac5b3811 (patch)
tree36cfe6e829774ae1720d951007f66f3ef2f6f9d2
parent448d2b9e9b1c673ea5c8dd6b8404b93d753cd569 (diff)
downloadvaadin-framework-7d4e5cb0a98fbc3c397c6c74385210e4ac5b3811.tar.gz
vaadin-framework-7d4e5cb0a98fbc3c397c6c74385210e4ac5b3811.zip
Adds naïve zebra striping to Grid (#13334)
Change-Id: Ia9a031f87065552688dffe3281bf647582b8f872
-rw-r--r--WebContent/VAADIN/themes/base/grid/grid.scss8
-rw-r--r--client/src/com/vaadin/client/ui/grid/Grid.java10
2 files changed, 16 insertions, 2 deletions
diff --git a/WebContent/VAADIN/themes/base/grid/grid.scss b/WebContent/VAADIN/themes/base/grid/grid.scss
index 69b293e26e..de30424d22 100644
--- a/WebContent/VAADIN/themes/base/grid/grid.scss
+++ b/WebContent/VAADIN/themes/base/grid/grid.scss
@@ -31,6 +31,14 @@
background: rgb(244,244,244);
}
}
+
+ .#{$primaryStyleName}-row > td {
+ background-color: #fff;
+ }
+
+ .#{$primaryStyleName}-row-stripe > td {
+ background-color: #eee;
+ }
.#{$primaryStyleName}-row-selected > td {
background: lightblue;
diff --git a/client/src/com/vaadin/client/ui/grid/Grid.java b/client/src/com/vaadin/client/ui/grid/Grid.java
index 7348ae2140..fe2157c7d3 100644
--- a/client/src/com/vaadin/client/ui/grid/Grid.java
+++ b/client/src/com/vaadin/client/ui/grid/Grid.java
@@ -762,6 +762,7 @@ public class Grid<T> extends ResizeComposite implements
private SelectionColumn selectionColumn;
+ private String rowStripeStyleName;
private String rowHasDataStyleName;
private String rowSelectedStyleName;
private String cellFocusStyleName;
@@ -1249,6 +1250,9 @@ public class Grid<T> extends ResizeComposite implements
setStyleName(rowElement, rowHasDataStyleName, hasData);
}
+ boolean isEvenIndex = (row.getRow() % 2 == 0);
+ setStyleName(rowElement, rowStripeStyleName, isEvenIndex);
+
// Assign stylename for selected rows
if (hasData) {
setStyleName(rowElement, rowSelectedStyleName,
@@ -1578,8 +1582,10 @@ public class Grid<T> extends ResizeComposite implements
escalator.setStylePrimaryName(style);
editorRow.setStylePrimaryName(style);
- rowHasDataStyleName = getStylePrimaryName() + "-row-has-data";
- rowSelectedStyleName = getStylePrimaryName() + "-row-selected";
+ String rowStyle = getStylePrimaryName() + "-row";
+ rowHasDataStyleName = rowStyle + "-has-data";
+ rowSelectedStyleName = rowStyle + "-selected";
+ rowStripeStyleName = rowStyle + "-stripe";
/*
* TODO rename CSS "active" to "focused" once Valo theme has been