From 4136d84671305e96358b50b0e6d6f996444bf9a7 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Fri, 23 Jan 2015 15:52:43 +0200 Subject: Fix Grid setting non-sortable column sortable (#16483) Change-Id: I7986ceb6ab1900bd1d5269c78c2f6b2e23c46334 --- server/src/com/vaadin/ui/Grid.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'server/src') diff --git a/server/src/com/vaadin/ui/Grid.java b/server/src/com/vaadin/ui/Grid.java index d77c6411ef..ab27a141b7 100644 --- a/server/src/com/vaadin/ui/Grid.java +++ b/server/src/com/vaadin/ui/Grid.java @@ -2154,11 +2154,20 @@ public class Grid extends AbstractComponent implements SelectionNotifier, public Column setSortable(boolean sortable) { checkColumnIsAttached(); - if (sortable && !(grid.datasource instanceof Sortable)) { - throw new IllegalStateException( - "Can't set column " - + toString() - + " sortable. The Container of Grid does not implement Sortable"); + if (sortable) { + if (!(grid.datasource instanceof Sortable)) { + throw new IllegalStateException( + "Can't set column " + + toString() + + " sortable. The Container of Grid does not implement Sortable"); + } else if (!((Sortable) grid.datasource) + .getSortableContainerPropertyIds().contains(propertyId)) { + throw new IllegalStateException( + "Can't set column " + + toString() + + " sortable. Container doesn't support sorting by property " + + propertyId); + } } state.sortable = sortable; -- cgit v1.2.3