Skip to content

Commit

Permalink
BondsView: Fix sorting of numeric columns
Browse files Browse the repository at this point in the history
The table in the BondsView uses string sorting by default. This results in unexpected behavior when sorting non-string columns.

This commit adds custom comparators to the numeric columns to address that.

Fixes #3231

Signed-off-by: cd2357 <[email protected]>
  • Loading branch information
cd2357 committed May 1, 2020
1 parent bb2484a commit 341833b
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ private void addColumns() {
column = new AutoTooltipTableColumn<>(Res.get("shared.amountWithCur", "BSQ"));
column.setMinWidth(80);
column.getStyleClass().add("first-column");
column.setComparator(Comparator.comparingLong(v -> v.getBond().getAmount()));
column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
column.setCellFactory(new Callback<>() {
@Override
Expand All @@ -189,6 +190,7 @@ public void updateItem(final BondListItem item, boolean empty) {
tableView.getColumns().add(column);
column = new AutoTooltipTableColumn<>(Res.get("dao.bond.table.column.lockTime"));
column.setMinWidth(40);
column.setComparator(Comparator.comparingInt(v -> v.getBond().getLockTime()));
column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
column.setCellFactory(new Callback<>() {
@Override
Expand Down Expand Up @@ -287,6 +289,7 @@ public void updateItem(final BondListItem item, boolean empty) {

column = new AutoTooltipTableColumn<>(Res.get("dao.bond.table.column.lockupDate"));
column.setMinWidth(140);
column.setComparator(Comparator.comparingLong(v -> v.getBond().getLockupDate()));
column.setCellValueFactory((item) -> new ReadOnlyObjectWrapper<>(item.getValue()));
column.setCellFactory(new Callback<>() {
@Override
Expand Down

0 comments on commit 341833b

Please sign in to comment.