From d27436b848dc03335f693d101b0e231fada69e26 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Thu, 31 May 2007 11:55:15 +0000 Subject: [PATCH] initial commit for #217 . also removed one illegal character in JS svn changeset:1540/svn branch:trunk --- src/com/itmill/toolkit/ui/Table.java | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) 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 @@ -218,6 +218,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. */ @@ -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"); } } -- 2.39.5