summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>2017-06-19 13:23:47 +0300
committerHenri Sara <henri.sara@gmail.com>2017-06-19 13:23:47 +0300
commitfa10456957a880e5860080a9dcccf39827c97700 (patch)
treeeb458b1660f0e5f4b668eb1f913aab3b6894478a /client
parent459188034ec56f2b9072ef426ba814b69a864996 (diff)
downloadvaadin-framework-fa10456957a880e5860080a9dcccf39827c97700.tar.gz
vaadin-framework-fa10456957a880e5860080a9dcccf39827c97700.zip
Fix displaying Grid sort order set from server (#9530)
Fixes #8316
Diffstat (limited to 'client')
-rw-r--r--client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java28
1 files changed, 25 insertions, 3 deletions
diff --git a/client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java b/client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java
index 0e234cc968..e94493757e 100644
--- a/client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java
+++ b/client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java
@@ -16,6 +16,7 @@
package com.vaadin.client.connectors.grid;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -419,6 +420,21 @@ public class GridConnector extends AbstractListingConnector
}
}
+ @OnStateChange({ "sortColumns", "sortDirs" })
+ void updateSortOrder() {
+ List<SortOrder> sortOrder = new ArrayList<SortOrder>();
+
+ String[] sortColumns = getState().sortColumns;
+ SortDirection[] sortDirs = getState().sortDirs;
+
+ for (int i = 0; i < sortColumns.length; i++) {
+ sortOrder
+ .add(new SortOrder(getColumn(sortColumns[i]), sortDirs[i]));
+ }
+
+ getWidget().setSortOrder(sortOrder);
+ }
+
@Override
public void setDataSource(DataSource<JsonObject> dataSource) {
super.setDataSource(dataSource);
@@ -501,9 +517,15 @@ public class GridConnector extends AbstractListingConnector
sortDirections.add(so.getDirection());
}
}
- getRpcProxy(GridServerRpc.class).sort(columnIds.toArray(new String[0]),
- sortDirections.toArray(new SortDirection[0]),
- event.isUserOriginated());
+ String[] colArray = columnIds.toArray(new String[0]);
+ SortDirection[] dirArray = sortDirections.toArray(new SortDirection[0]);
+
+ if (!Arrays.equals(colArray, getState().sortColumns)
+ || !Arrays.equals(dirArray, getState().sortDirs)) {
+ // State has actually changed, send to server
+ getRpcProxy(GridServerRpc.class).sort(colArray, dirArray,
+ event.isUserOriginated());
+ }
}
/* HasComponentsConnector */