Rowsorting of TableView with SortedList/FilteredList
grazertwo at gmail.com
Mon Aug 12 04:14:47 PDT 2013
Sorry for the link I had that in the original mail but by adding it seems
to have vanished.
So I had a chance to test the TableView with SortedList and FilteredList
Sorting is enabled with SortedList but not with FilteredList. I guess
you'll want a issue for filtering with FilteredList?
However I've run into a range of Exception in conjunction with SortedLists
created from FilteredList as item in TableView and user ordering of Columns
and user based changes of the FilteredList.predicate. They range from
ArrayIndexOutOfBoundsException out of SortedList.java:313 to
IndexOutOfBoundsException caused by TextInputControlBehavior.java:334 and
NullPointerException in SortedList.java:247.
I've built a small test class a user has to interact with. We've searched
for some automatic way of reproducing the error to no avail (up to now).
Steps to reproduce:
1) change column sort of any column
2) type two characters in the textfield below which will change the
FilterList.predicate based on String.startsWith-condition.
On Thu, Aug 8, 2013 at 10:30 PM, Jonathan Giles
<jonathan.giles at oracle.com>wrote:
> Funny you should ask about this - I just blogged about SortedList and
> TableView the other day, over at FXExperience:
> Of course, I can see that you've already read that post (I see a comment
> from the code in my post in your code below). What might have been missed
> is that I noted earlier on in the blog post I had to make a few small
> changes to properly get SortedList support in TableView, so you'll want to
> try again in b102 (or b103).
> Regarding your use of FilteredList as well - I've not tried this at all,
> but I'll add it to my todo list to investigate today. I imagine there might
> be a bug somewhere. Whatever I find will probably make for a good post at
> FXExperience, so keep an eye out there too.
> Thanks, and if you do run into further issues, please don't hesitate to
> file bugs. In general, if TableView isn't sorting then something is going
> really wrong!
> -- Jonathan
> On 8/08/2013 11:17 p.m., Martin Klähn wrote:
>> Hi guys,
>> I'm working on a business application that makes use of TableView and I'm
>> working with JDK 8 build b101.
>> Displaying the data works like a charm. Row sorting for ordinary
>> ObservableLists is fine too.
>> Then I've set TableView.items to FilteredList and row sorting was
>> replacing TableView.item with SortedList does not allow row sorting as
>> well. Binding the comparator of SortedList to the TableView.comparator has
>> no effect either.
>> // row sorting possible
>> //final TableView<Integer> tableView = new
>> TableView<>(FXCollections.**observableArrayList(2, 1, 3));
>> // row sorting not possible (SortedList)
>> // create a TableView with the sorted list set as the items it will show
>> // bind the sortedList comparator to the TableView comparator
>> //SortedList<Integer> sortedList = new
>> SortedList<>(FXCollections.**observableArrayList(2, 1, 3));
>> //final TableView<Integer> tableView = new TableView<>(sortedList);
>> // row sorting not possible (FilteredList)
>> //FilteredList<Integer> filteredList = new
>> FilteredList<>(FXCollections.**observableArrayList(2, 1, 3), (e) ->
>> //final TableView<Integer> tableView = new TableView<>(filteredList );
>> // Don't forget to define columns!
>> final TableColumn<Integer, Number> integerColumn = new
>> final TableColumn<Integer, String> hexColumn = new TableColumn<>("Integer
>> integerColumn.**setCellValueFactory(javaClass -> new
>> hexColumn.setCellValueFactory(**javaClass -> new
>> tableView.getColumns().addAll(**integerColumn, hexColumn);
>> Any pointers on what I'm doing wrong or where I have to adapt my
>> Is it correct that row sorting in a TableView is only possible for
>> With Regards
More information about the openjfx-dev