Instant search Javafx


// --------------------------Filter function and
// code-------------------------------------------------------------------------------

FilteredList filterList = new FilteredList<>(dataSolicitari, p -> true);

SortedList sortableData;

int idStringTemp;
String SolictareTemp;
String umTemp;
String ManoperaTemp;
String statusTemp;

public void initFilter() {

// ---- filter by id -----------

text1.textProperty().addListener((obsVal, oldValue, newValue) -> {

filterList.setPredicate(SolicitariModel -> {

idStringTemp = SolicitariModel.getId();
SolictareTemp = SolicitariModel.getDenumire();
umTemp = SolicitariModel.getUm();
ManoperaTemp = String.valueOf(SolicitariModel.getManopera());
statusTemp = String.valueOf(SolicitariModel.isInactiv() ? 1 : 0);

if (String.valueOf(idStringTemp).toLowerCase().contains(text1.getText().toLowerCase())
&& String.valueOf(SolictareTemp).toLowerCase().contains(text2.getText().toLowerCase())
&& String.valueOf(umTemp).toLowerCase().contains(text3.getText().toLowerCase())
&& String.valueOf(ManoperaTemp).toLowerCase().contains(text4.getText().toLowerCase())
&& String.valueOf(statusTemp).toLowerCase().contains(IdActive.toLowerCase())

)

{
return true;
}
return false;

});
});

// --------------------------------------------------------------------

sortableData = new SortedList<>(filterList);
tblNomenSolicitari.setItems(sortableData);

sortableData.comparatorProperty().bind(tblNomenSolicitari.comparatorProperty());

Leave a Comment

Your email address will not be published. Required fields are marked *