Reputation: 4349
Firstly, I am working on Windows 7, Netbeans 8, JDK 8.
I have a TableView
containing POJO
objects (not using properties).
I am trying to implement "search while typing" but something strange happens.
In this image you can see that ALL the students are being displayed:
In the next picture after the search is done you can see the problem.
First 4 students are the actual search results and are clickable active entries in the TableView
.
All the others entries are visible but not responding, but instead they should have been removed completely.
How it works (coding part):
1. When users types 'f' a function is called.
2. In the function I create new list that will contain the search results:
ObservableList<Student> subentries = FXCollections.observableArrayList();
3. Then I add all items matching the criteria of the search in subentries
list
4. I call:
5. studentsTable.setItems(subentries);
Erroneous result is shown in picture 2.
HACKS I tried:
1. randomButton.fire();
2.
columnsOfTheTable.get(0).setVisible(false);
columnsOfTheTable.get(0).setVisible(true);
The above don't work.
Any help would be appreciated.
Thanks
Upvotes: 0
Views: 584
Reputation: 209553
This is a bit of a guess, but if you are using custom cells (or rows) in your table, make sure their updateItem(...)
methods properly handle empty cells:
@Override
public void updateItem(SomeType item, boolean empty) {
super.updateItem(item, boolean);
if (empty) {
setText(null);
setGraphic(null);
} else {
// configure cell...
}
}
Upvotes: 6