TableView项目不会被删除但不响应 [英] TableView items are not removed but do not respond
问题描述
首先,我正在开发Windows 7,Netbeans 8,JDK 8.
我有一个 TableView
包含 POJO
对象(不使用属性)。
我正在尝试实现在键入时进行搜索,但发生了一些奇怪的事情。
在此图片中,您可以看到所有学生都在显示:
在搜索完成后的下一张图片中,您可以看到问题。
前4名学生是实际的搜索结果,并且是 TableView
中的可点击活动条目。
所有其他条目都可见但没有回应,但他们应该完全删除。
工作原理 (编码部分):
1.当用户输入'f'时,调用一个函数。
2.在function我创建了包含搜索结果的新列表:
ObservableList< Student> subentries = FXCollections.observableArrayList();
3.然后我在子条目中添加符合搜索条件的所有项目
list
4.我打电话:
5. studentsTable.setItems(子条目);
错误结果如图2所示。
HACKS我试过:
1. randomButton.fire();
2.
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);
以上不起作用。
任何帮助都将不胜感激。< br>
谢谢
The above don't work.
Any help would be appreciated.
Thanks
推荐答案
这是一个猜测,但如果您使用自定义单元格(或行),确保他们的 updateItem(...)
方法正确处理空单元格:
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...
}
}
这篇关于TableView项目不会被删除但不响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!