summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/ui/Grid.java
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/com/vaadin/ui/Grid.java')
-rw-r--r--server/src/com/vaadin/ui/Grid.java23
1 files changed, 15 insertions, 8 deletions
diff --git a/server/src/com/vaadin/ui/Grid.java b/server/src/com/vaadin/ui/Grid.java
index ee7da1e36c..b8b5040b13 100644
--- a/server/src/com/vaadin/ui/Grid.java
+++ b/server/src/com/vaadin/ui/Grid.java
@@ -31,7 +31,6 @@ import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -2840,13 +2839,15 @@ public class Grid extends AbstractComponent implements SelectionNotifier,
setFrozenColumnCount(columns.size());
}
- // Update sortable columns
- if (event.getContainer() instanceof Sortable) {
- Collection<?> sortableProperties = ((Sortable) event
- .getContainer()).getSortableContainerPropertyIds();
- for (Entry<Object, Column> columnEntry : columns.entrySet()) {
- columnEntry.getValue().setSortable(
- sortableProperties.contains(columnEntry.getKey()));
+ // Unset sortable for non-sortable columns.
+ if (datasource instanceof Sortable) {
+ Collection<?> sortables = ((Sortable) datasource)
+ .getSortableContainerPropertyIds();
+ for (Object propertyId : columns.keySet()) {
+ Column column = columns.get(propertyId);
+ if (!sortables.contains(propertyId) && column.isSortable()) {
+ column.setSortable(false);
+ }
}
}
}
@@ -3507,6 +3508,12 @@ public class Grid extends AbstractComponent implements SelectionNotifier,
column.setHeaderCaption(SharedUtil.propertyIdToHumanFriendly(String
.valueOf(datasourcePropertyId)));
+ if (datasource instanceof Sortable
+ && ((Sortable) datasource).getSortableContainerPropertyIds()
+ .contains(datasourcePropertyId)) {
+ column.setSortable(true);
+ }
+
return column;
}