I've created https://javafx-jira.kenai.com/browse/RT-32391 for the problem that TableView is not sortable with a FilteredList
- Martin On Mon, Aug 12, 2013 at 1:14 PM, Martin Klähn <grazer...@gmail.com> wrote: > 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 > with b102. > > 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). > See https://www.dropbox.com/s/bfhqm0xk4y9r1oz/FilterSortedList.java > > 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. > > Regards, > Martin > > > > On Thu, Aug 8, 2013 at 10:30 PM, Jonathan Giles <jonathan.gi...@oracle.com > > wrote: > >> Funny you should ask about this - I just blogged about SortedList and >> TableView the other day, over at FXExperience: >> http://fxexperience.com/2013/**08/returning-a-tableview-back-** >> to-an-unsorted-state-in-**javafx-8-0<http://fxexperience.com/2013/08/returning-a-tableview-back-to-an-unsorted-state-in-javafx-8-0> >> >> 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 >>> disabled. >>> 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)); >>> //sortedList.**comparatorProperty().bind(** >>> tableView.comparatorProperty()**); >>> //final TableView<Integer> tableView = new TableView<>(sortedList); >>> >>> // row sorting not possible (FilteredList) >>> //FilteredList<Integer> filteredList = new >>> FilteredList<>(FXCollections.**observableArrayList(2, 1, 3), (e) -> >>> true); >>> //final TableView<Integer> tableView = new TableView<>(filteredList ); >>> >>> // Don't forget to define columns! >>> final TableColumn<Integer, Number> integerColumn = new >>> TableColumn<>("Integer"); >>> final TableColumn<Integer, String> hexColumn = new TableColumn<>("Integer >>> Hex"); >>> >>> integerColumn.**setCellValueFactory(javaClass -> new >>> SimpleLongProperty(javaClass.**getValue())); >>> hexColumn.setCellValueFactory(**javaClass -> new >>> SimpleStringProperty(Integer.**toHexString(javaClass.**getValue()))); >>> >>> tableView.getColumns().addAll(**integerColumn, hexColumn); >>> >>> >>> Any pointers on what I'm doing wrong or where I have to adapt my >>> expectations. >>> Is it correct that row sorting in a TableView is only possible for >>> ordinary >>> ObservableLists? >>> >>> >>> With Regards >>> Martin >>> >> >> >