You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my use case the filter is empty. It appears the ComboBox doesn't pass it at all; I assume this is because the ComboBox has been set up to do client-side filtering based on how it was constructed?
The combobox never called setFilter of the FilterablePageableDataProvider and FilterablePageableDataProvider does not use the query filter given by the combobox.
If you change the FilterablePageableDataProvider to this:
package org.vaadin.artur.spring.dataprovider;
import com.vaadin.flow.data.provider.Query;
import java.util.Optional;
import java.util.stream.Stream;
public abstract class FilterablePageableDataProvider<T, F> extends PageableDataProvider<T, F> {
private F filter = null;
public FilterablePageableDataProvider() {
}
public void setFilter(F filter) {
if (filter == null) {
throw new IllegalArgumentException("Filter cannot be null");
} else {
this.filter = filter;
this.refreshAll();
}
}
public int size(Query<T, F> query) {
return super.size(this.getFilterQuery(query));
}
public Stream<T> fetch(Query<T, F> query) {
return super.fetch(this.getFilterQuery(query));
}
private Query<T, F> getFilterQuery(Query<T, F> t) {
/// Use the query filter if it exists else use the external filter
F filter = t.getFilter().orElse(this.filter);
return new Query(t.getOffset(), t.getLimit(), t.getSortOrders(), t.getInMemorySorting(), filter);
}
protected Optional<F> getOptionalFilter() {
return this.filter == null ? Optional.empty() : Optional.of(this.filter);
}
}
The filtering is working.
I'm not sure if my fix is the right one, but I think the problem is not related to the combobox.
If you try to filter the combobox in the order editor in the Bakery Demo. The combobox is not filtered.
If you add a breakpoint in FilterablePageableDataProvider in fetch(Query<T, F> query).
The query filter is set but it's ignored.
See the forum post here: https://vaadin.com/forum/thread/18354860/combo-boxes-not-filtering-as-expected
The text was updated successfully, but these errors were encountered: