Example usage for javafx.scene.control TableView getSortOrder

List of usage examples for javafx.scene.control TableView getSortOrder

Introduction

In this page you can find the example usage for javafx.scene.control TableView getSortOrder.

Prototype

public final ObservableList<TableColumn<S, ?>> getSortOrder() 

Source Link

Document

The sortOrder list defines the order in which TableColumn instances are sorted.

Usage

From source file:com.ggvaidya.scinames.dataset.DatasetSceneController.java

private void fillTableWithChanges(TableView<Change> tv, Dataset tp) {
    // Preserve search order and selected item.
    List<TableColumn<Change, ?>> sortByCols = new LinkedList<>(tv.getSortOrder());
    List<Change> selectedChanges = new LinkedList<>(tv.getSelectionModel().getSelectedItems());

    LOGGER.info("About to set changes table items: sortByCols = " + sortByCols + ", selectedChanges = "
            + selectedChanges);//from w w w.  j  a  v  a2  s . co m
    tv.setItems(FXCollections.observableList(tp.getAllChangesAsList()));
    LOGGER.info("tv.setItems() completed");

    for (Change ch : selectedChanges) {
        tv.getSelectionModel().select(ch);
    }
    tv.getSortOrder().addAll(sortByCols);
    LOGGER.info("fillTableWithChanges() completed");
}