2

Is there a way to filter table columns data as there is a way in excel to filter. Filtering manually require a very long code if data is huge. So trying to find an easy way. Please suggest something. I went through the following link for the same but need an easier and efficient approach. http://code.makery.ch/blog/javafx-8-tableview-sorting-filtering/

4
  • 1
    The link you gave is the easiest and most efficient way I could think of for implementing what you want. What's your problem with it? Commented Mar 6, 2015 at 6:50
  • If I have thousand rows with different data and I want to view just few then this process seems to be tedious to me. I want exactly the same feature of filtering as provided by microsoft excel. Commented Mar 6, 2015 at 9:54
  • 2
    Why can't you use the methods in that link to create a filter similar to the one in Excel? You probably need to create and post a simple example to show what you have tried. Commented Mar 6, 2015 at 13:25
  • Actually what i need to ask that is there a direct way inbuilt in javafx like there is tablemenubutton, sorting functions. Similarly in javafx, in there any inbuilt functionality for filtering? Commented Mar 10, 2015 at 5:54

2 Answers 2

4

There's no built-in filter capability for TableViews like Excel.

I've written a library that provides the GUI filters, but you'll still need to programmatically apply the results to filter your dataset:

https://code.google.com/p/javafx-filterable-table-columns/

https://github.com/jhsheets/javafx-filterable-table-columns

Sign up to request clarification or add additional context in comments.

Comments

3

I wrote an extension for that use case:

https://github.com/maimArt/TableFilterFX

The implementation of the filter is quite easy. You wrap your TableView with the TableFilter and add the columns that should be filterd by tableFilter.filterColumn(TableColumn column)

1 Build your TableView like usual by code or fxml
TableView<Pojo> table = new TableView<>(); table.getItems().addAll(pojoList); TableColumn<Pojo, String> columnA = new TableColumn<>("ColA"); TableColumn<Pojo, String> columnB = new TableColumn<>("ColB"); table.getColumns().add(columnA); table.getColumns().add(columnB); 
2 After that apply the filter
TableFilter<Pojo> tableFilter = new TableFilter<>(table); tableFilter.filterColumn(columnA); tableFilter.filterColumn(columnB); 

3 Comments

Please don't just post some tool or library as an answer. At least demonstrate how it solves the problem in the answer itself.
Looks better now, thanks. (Not my downvote btw, I lack domain knowledge to vote on this.)
Thank you for your feedback. Hope the downvoter can also give me some feedback to improve my behaviour or code.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.