summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorJohn Ahlroos <john@vaadin.com>2013-12-03 10:54:53 +0200
committerJohn Ahlroos <john@vaadin.com>2013-12-04 14:48:59 +0200
commit428c5801da9f2d9248ad35c385b329a2f80c33b9 (patch)
tree0f20d27025679c5333dc70e1684219256d6e27fd /client
parent3e64013806a9e4f06babe33d1f0c66a5ff371798 (diff)
downloadvaadin-framework-428c5801da9f2d9248ad35c385b329a2f80c33b9.tar.gz
vaadin-framework-428c5801da9f2d9248ad35c385b329a2f80c33b9.zip
Support custom column widths in Grid #13024
Change-Id: Ib0c1701346dc6b8b9ef5b5290fc6ffaff68d9f96
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/ui/grid/Grid.java16
-rw-r--r--client/src/com/vaadin/client/ui/grid/GridConnector.java1
2 files changed, 17 insertions, 0 deletions
diff --git a/client/src/com/vaadin/client/ui/grid/Grid.java b/client/src/com/vaadin/client/ui/grid/Grid.java
index 25e6596a35..8d8d22d61c 100644
--- a/client/src/com/vaadin/client/ui/grid/Grid.java
+++ b/client/src/com/vaadin/client/ui/grid/Grid.java
@@ -298,6 +298,22 @@ public class Grid<T> extends Composite {
private int findIndexOfColumn() {
return grid.columns.indexOf(this);
}
+
+ /**
+ * Sets the pixel width of the column. Use a negative value for the grid
+ * to autosize column based on content and available space
+ *
+ * @param pixels
+ * the width in pixels or negative for auto sizing
+ */
+ public void setWidth(int pixels) {
+ if (grid != null) {
+ int index = findIndexOfColumn();
+ ColumnConfiguration conf = grid.escalator
+ .getColumnConfiguration();
+ conf.setColumnWidth(index, pixels);
+ }
+ }
}
/**
diff --git a/client/src/com/vaadin/client/ui/grid/GridConnector.java b/client/src/com/vaadin/client/ui/grid/GridConnector.java
index 47558b2f22..ffe1444942 100644
--- a/client/src/com/vaadin/client/ui/grid/GridConnector.java
+++ b/client/src/com/vaadin/client/ui/grid/GridConnector.java
@@ -181,6 +181,7 @@ public class GridConnector extends AbstractComponentConnector {
column.setVisible(state.visible);
column.setHeaderCaption(state.header);
column.setFooterCaption(state.footer);
+ column.setWidth(state.width);
}
/**