I am trying to add a search filter to a Javafx gui. I need to filter by the products id number, and have tried a series of different methods in order to add it to the if (else) block of searchable items without success. It currently will search for the text items, as well as the row number, but not the id column value. The documentation I saw only references string values. Any tips would be appreciated.
FilteredList<Part>filteredData = new FilteredList<>(allParts,p->true);
partsSearchBox.textProperty().addListener((observable,oldValue,newValue) -> {
filteredData.setPredicate(part -> {
if (newValue == null || newValue.isEmpty()) {
return true;
}
String lowerCaseFilter = newValue.toLowerCase();
if (part.getPartName().toLowerCase().contains(lowerCaseFilter)) {
return true;
}
return false;
});
});
SortedList<Part> sortedData = new SortedList<>(filteredData);
sortedData.comparatorProperty().bind(partsTableview.comparatorProperty());
partsTableview.setItems(sortedData);
Aucun commentaire:
Enregistrer un commentaire