use of com.vaadin.event.SortEvent.SortListener in project VaadinUtils by rlsutton1.
the class BasePortal method setupGridSorting.
public void setupGridSorting(final Grid grid, final String keySorting) {
if (sortListeners.get(grid) != null) {
grid.removeSortListener(sortListeners.get(grid));
} else {
SortListener sortListener = new SortListener() {
private static final long serialVersionUID = 1L;
@Override
public void sort(SortEvent event) {
String sorts = "";
for (SortOrder sort : event.getSortOrder()) {
sorts += sort.getPropertyId() + "=" + sort.getDirection() + ",";
}
getConfigDelegate().setValue(getPortal(), keySorting, sorts);
}
};
sortListeners.put(grid, sortListener);
}
String sorts = getConfigDelegate().getValueString(getPortal(), keySorting);
if (StringUtils.isNotEmpty(sorts)) {
try {
List<SortOrder> sortList = new LinkedList<>();
String[] sortArray = sorts.split(",");
for (String sort : sortArray) {
String[] parts = sort.split("=");
sortList.add(new SortOrder(parts[0], SortDirection.valueOf(parts[1])));
}
grid.setSortOrder(sortList);
} catch (Exception e) {
logger.error(e);
}
}
grid.addSortListener(sortListeners.get(grid));
}
Aggregations