Multiple filter with TableView in javafx

I created a table in javafx2.2 with a filter to filter data. For example, I have two columns of the type (First Name, Last Name). The "Name" column has the same name on many rows with different Last Name. So I would like to add two filters to filter First Name, and I like to filter the last name based on the name filter.

+1
source share
1 answer

Take a look at the TableView#getSortOrder :

 public final ObservableList<TableColumn<S,?>> getSortOrder() Returns: An ObservableList containing zero or more TableColumn instances. 

The sortOrder list determines the sort order of the TableColumn instances:

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

You just need to put the first and last columns where previously setSortable(true) called both columns.

+1
source

Source: https://habr.com/ru/post/1485363/


All Articles