- changed status to invalid
Sorting by TableColumn
Hi there,
I think I have found a bug.
I have created a simple TableControl with some sample data:
List<TCItem> testList = new ArrayList<TCItem>();
TCItem test1 = new TCItem();
test1.setTestA("A");
test1.setTestB("B");
test1.setTestC("C");
TCItem test2 = new TCItem();
test2.setTestA("AAB");
test2.setTestB("BBC");
test2.setTestC("BBC");
testList.add(test1);
testList.add(test2);
ObservableList<TCItem> testListOL = FXCollections.observableArrayList(testList);
tv.setItems(testListOL);
TableControl<TCItem> tc = new TableControl<TCItem>();
tc.addColumn(new TextColumn<TCItem>("testA"));
tc.addColumn(new TextColumn<TCItem>("testB"));
tc.addColumn(new TextColumn<TCItem>("testC"));
tc.setController(new TableController<TCItem>() {
@Override
public TableData<TCItem> loadData(int startIndex, List<TableCriteria> filteredColumns, List<String> sortedColumns,
List<SortType> sortingOrders, int maxResult) {
List<TCItem> testList = new ArrayList<TCItem>();
TCItem test1 = new TCItem();
test1.setTestA("A");
test1.setTestB("B");
test1.setTestC("C");
TCItem test2 = new TCItem();
test2.setTestA("AAB");
test2.setTestB("BBC");
test2.setTestC("BBC");
testList.add(test1);
testList.add(test2);
return new TableData<TCItem>(testList, false, testList.size());
}
});
First of all, when I click the TableColumn header nothing happens...in the default TableView of JavaFX the sorting is a out of the box feature, why not in TableControl?
However, when I edit a cell and I do not press the save button but click on a column header, the revert or cancel reload message dialog pops up, which is ok, but when I click on cancel reload the table does sort.
I added a gif to visualize it better.
Now is this a bug or a feature? It would be nice if default TableView sorting would work.
Comments (3)
-
-
reporter Sure, I did take a look at it. But you are presuming that people are only using sql connection. For me, e.g.this is not the case (I am using a Web service resp. Excel data) but I had to rewrite sorting method, even though TableView has this functionality implemented... I did get your point, but try to see the issue from a not sql user :) Thank you
Best regards
-
hmm i am trying to get a sort by speficil column on load , but i can't figure out how. I am using the Daobase from tiwulfx demo
- Log in to comment
This is not an issue. Sorting and pagination should happen in back end. TableControl displays records as is. Take a look at TableControl.loadData parameters: startIndex, filteredColumns, sortedColumns, sortingOrders, maxResult. They are inputs to form sql query like: select * from aTable where <filteredColumns> limit startIndex,maxResult order by <sortedColumns sortingOrders>