I have a Crud, which uses a CrudGrid that I set up and configure manually, with my own filter fields in the column headers.
The CrudGrid used to be a normal Grid before my current refactoring, and it used a ListDataProvider where I could reset the filter on the fly when a value of a filter input field has changed. I did this like so:
// method called at value change of any filter field
private void onFilterChange(){
ListDataProvider<Foo> dataProvider = (ListDataProvider<Foo>) grid.getDataProvider();
dataProvider.setFilter((item) -> {
boolean firstNameMatch = item.getFirstName().contains(firstNameFilterField.getValue());
boolean lastNameMatch = item.getLastName().contains(lastNameFilterField.getValue());
boolean fooBarEnumMatch = item.getFooBarEnum().equals(fooBarEnumFilterField.getValue());
return firstNameMatch && lastNameMatch && fooBarEnumMatch;
}
}
But now that my grid has a CrudDataProvider, I can no longer call setFilter.
I can see in the method CrudGrid::setupFiltering how the default filters would be set up. But they will all be TextFields - I want to have some ComboBoxes as well to filter enum fields, or using equals instead of contains for some columns, etc.
When debugging I can see that the constraints list of the CrudFilter are being filled up as expected. But the grid is not being filtered as result.
All that happens is I get many many many log warnings: [WARN ] com.vaadin.flow.server.communication.rpc.AbstractRpcInvocationHandler - Got an RPC for non-existent node: 1906
I have also tried using column keys that match the respective property name exactly, that did not help.
I saw that my implementation of fetchFromBackEnd in the dataprovider did not filter the stream based on query.getFilter() as shown in the [example code]
(https://vaadin.com/components/vaadin-crud/java-examples) (PersonDataProvider). Of course the filtering didn’t work like this. It works now, sorry for the bother.