aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatti Tahvonen <matti.tahvonen@itmill.com>2007-05-31 11:55:15 +0000
committerMatti Tahvonen <matti.tahvonen@itmill.com>2007-05-31 11:55:15 +0000
commitd27436b848dc03335f693d101b0e231fada69e26 (patch)
tree777e014ee5c78d41c8a55eb061e02a5a94793e5f
parentfbc5e3d0cf6b98396fe5197e33220bb1dc23a742 (diff)
downloadvaadin-framework-d27436b848dc03335f693d101b0e231fada69e26.tar.gz
vaadin-framework-d27436b848dc03335f693d101b0e231fada69e26.zip
initial commit for #217 . also removed one illegal character in JS
svn changeset:1540/svn branch:trunk
-rw-r--r--src/com/itmill/toolkit/ui/Table.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/com/itmill/toolkit/ui/Table.java b/src/com/itmill/toolkit/ui/Table.java
index e0cc144add..071fe84169 100644
--- a/src/com/itmill/toolkit/ui/Table.java
+++ b/src/com/itmill/toolkit/ui/Table.java
@@ -219,6 +219,11 @@ public class Table extends Select implements Action.Container,
private HashMap columnAlignments = new HashMap();
/**
+ * Holds column widths in pixels for visible columns (by propertyId).
+ */
+ private HashMap columnWidths = new HashMap();
+
+ /**
* Holds value of property pageLength. 0 disables paging.
*/
private int pageLength = 15;
@@ -614,6 +619,31 @@ public class Table extends Select implements Action.Container,
// Assures the visual refresh
refreshCurrentPage();
}
+
+ /**
+ * Sets columns width (in pixels). Theme may not necessary respect very
+ * small or very big values. Setting width to -1 (default) means that theme
+ * will make decision of width.
+ *
+ * @param columnId colunmns property id
+ * @param width width to be reserved for colunmns content
+ * @since 4.0.3
+ */
+ public void setColumnWidth(Object columnId, int width) {
+ columnWidths.put(columnId, new Integer(width));
+ }
+
+ /**
+ * Gets the width of column
+ * @param propertyId
+ * @return width of colun or -1 when value not set
+ */
+ public int getColumnWidth(Object propertyId) {
+ Integer value = (Integer) columnWidths.get(propertyId);
+ if(value == null)
+ return -1;
+ return value.intValue();
+ }
/**
* Gets the page length.
@@ -1433,6 +1463,8 @@ public class Table extends Select implements Action.Container,
if (!ALIGN_LEFT.equals(this.getColumnAlignment(columnId)))
target.addAttribute("align", this
.getColumnAlignment(columnId));
+ if(getColumnWidth(columnId) > -1)
+ target.addAttribute("width", String.valueOf(getColumnWidth(columnId)));
target.endTag("ch");
}
}