Raman S
Raman S

Reputation: 23

Multiple filter with TableView in javafx

I have created table in javafx2.2 with filter for filtering data. For example I have two columns like (First Name , Last Name). The First Name column has same name in many rows with different Last Name. So i would like to add two filter for filtering First Name then i like to filter Last Name Based on First Name Filter.

Upvotes: 1

Views: 2369

Answers (1)

Alexander Kirov
Alexander Kirov

Reputation: 3654

Look at the TableView#getSortOrder method :

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

Returns:
An ObservableList containing zero or more TableColumn instances.

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

  • An empty sortOrder list means that no sorting is being applied to the TableView.
  • If the sortOrder list contains only one TableColumn, TableView will be sorted using the sortType and comparator properties of this TableColumn (assuming TableColumn.sortable is true).
  • If the sortOrder list contains multiple TableColumn instances, then TableView is initially sorted based on the properties of the first TableColumn. If two elements are considered equal, then the second TableColumn in the list is used to determine ordering. This repeats until the results from all TableColumn comparators are considered, if necessary.

You just have to put first and last columns there having previously setSortable(true) called for both columns.

Upvotes: 1

Related Questions