Skip to content

Conversation

@peholmst
Copy link
Member

@peholmst peholmst commented Dec 12, 2025

Fixes #3842.

This is my outcome from the AI workshop. Claude wrote all the code according to my specifications. This PR:

  • Introduces a new set of methods, setItemsWithFilter that accept a fetch callback, a fetch/count callback pair, and a backend data provider, respectively, with a non-void filter type.
  • Introduces a new GridLazyFilterDataView type that makes it possible to set a filter.

This maintains backwards compatibility with the existing methods and types without introducing new generic type parameters.

@CLAassistant
Copy link

CLAassistant commented Dec 12, 2025

CLA assistant check
All committers have signed the CLA.

@peholmst peholmst marked this pull request as ready for review December 12, 2025 09:02
@sonarqubecloud
Copy link

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to figure out what the intended benefit here is, or how much of a benefit compared to adding to the API confusion around setItems / setItemsPageable / setDataProvider.

So for example, how is this approach better than this:

var filterableDataProvider = new CallbackDataProvider<String, String>(query -> Stream.empty(), query -> 0)
        .withConfigurableFilter();

grid.setItems(filterableDataProvider);

filterableDataProvider.setFilter("test");

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach you suggested requires a count callback. If I want to use just a fetch callback, I'd have to write:

var filterableDataProvider = new CallbackDataProvider<String, String>(
  query -> Stream.empty(),
  query -> { throw new UnsupportedOperationException(""); }
).withConfigurableFilter();

grid.setItems(filterableDataProvider);
grid.getLazyDataView().setItemCountUnknown();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Grid] setItems should accept filterable data providers

3 participants