You can also filter lazy data providers, e.g. a CallBackDataProvider; the second type parameter of
DataProvider<POJOTYPE, FILTERTYPE> myProvider =
DataProvider.fromFilteringCallbacks(query -> ..., query -> ...);
is the type of the Filter object (usually a String). You need to use a configurable filter data provider wrapper object to add a filter dynamically:
ConfigurableFilterDataProvider<POJOTYPE, Void, FILTERTYPE> filteredProvider
= dataProvider.withConfigurableFilter();
myGrid.setDataProvider(filteredProvider);
Then you can just do this to filter:
filteredProvider.setFilter(filterObject); // maybe filterObject = "myFilterString";
The filter object will find its way to your Query objects as an Optional (see the original fromFilteringCallbacks) and you can use that when doing your backend data queries.
So to answer Fabio’s original question shortly, you need to take your data provider creation out of the setDataProvider() call and use a ConfigurableFilterDataProvider wrapper to add filtering.