From 179c1f681de4d20aaecf578500f7a49a440a9049 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Tue, 29 Jan 2008 14:55:08 +0000 Subject: [PATCH] fixes #97 svn changeset:3666/svn branch:trunk --- src/com/itmill/toolkit/ui/Table.java | 51 +++++++++++++++++++++------- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/src/com/itmill/toolkit/ui/Table.java b/src/com/itmill/toolkit/ui/Table.java index 951f0c972f..9efe526db2 100644 --- a/src/com/itmill/toolkit/ui/Table.java +++ b/src/com/itmill/toolkit/ui/Table.java @@ -1322,14 +1322,14 @@ public class Table extends AbstractSelect implements Action.Container, } } - // Sorting - boolean doSort = false; if (!sortDisabled) { + // Sorting + boolean doSort = false; if (variables.containsKey("sortcolumn")) { final String colId = (String) variables.get("sortcolumn"); if (colId != null && !"".equals(colId) && !"null".equals(colId)) { final Object id = columnIdMap.get(colId); - setSortContainerPropertyId(id); + setSortContainerPropertyId(id, false); doSort = true; } } @@ -1337,13 +1337,13 @@ public class Table extends AbstractSelect implements Action.Container, final boolean state = ((Boolean) variables.get("sortascending")) .booleanValue(); if (state != sortAscending) { - setSortAscending(state); + setSortAscending(state, false); doSort = true; } } - } - if (doSort) { - this.sort(); + if (doSort) { + this.sort(); + } } // Dynamic column hide/show and order @@ -2345,15 +2345,28 @@ public class Table extends AbstractSelect implements Action.Container, * the Container property id of the currently sorted column. */ public void setSortContainerPropertyId(Object propertyId) { + setSortContainerPropertyId(propertyId, true); + } + + /** + * Internal method to set currently sorted column property id. With doSort + * flag actual sorting may be bypassed. + * + * @param propertyId + * @param doSort + */ + private void setSortContainerPropertyId(Object propertyId, boolean doSort) { if ((sortContainerPropertyId != null && !sortContainerPropertyId .equals(propertyId)) || (sortContainerPropertyId == null && propertyId != null)) { sortContainerPropertyId = propertyId; - sort(); - } - // Assures the visual refresh - refreshCurrentPage(); + if (doSort) { + sort(); + // Assures the visual refresh + refreshCurrentPage(); + } + } } /** @@ -2374,11 +2387,23 @@ public class Table extends AbstractSelect implements Action.Container, * descending. */ public void setSortAscending(boolean ascending) { + setSortAscending(ascending, true); + } + + /** + * Internal method to set sort ascending. With doSort flag actual sort can + * be bypassed. + * + * @param ascending + * @param doSort + */ + private void setSortAscending(boolean ascending, boolean doSort) { if (sortAscending != ascending) { sortAscending = ascending; - sort(); + if (doSort) { + sort(); + } } - // Assures the visual refresh refreshCurrentPage(); } -- 2.39.5