Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating a filter programmatically is not easy #179

Open
uap-universe opened this issue Jan 23, 2025 · 0 comments
Open

Updating a filter programmatically is not easy #179

uap-universe opened this issue Jan 23, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@uap-universe
Copy link
Collaborator

Current Behavior

When you try to update a filter, you probably want to use

this.source.setFilter([{
    field: 'timestamp',
    search: myquery,
}]);

Problem No. 1 : this erases all previous filter.

But that is solved by using addFilter, which updates existing filter or adds a new one:

this.source.addFilter([{
    field: 'timestamp',
    search: myquery,
}]);

But this leads to Problem No. 2 : this erases a possible filter function from the column settings.

That means, you are supposed to write something like this

this.source.addFilter([{
    field: 'timestamp',
    search: myquery,
    filter: DateFunctions.onTimestampFilter,
}]);

repeating the correct filter function from the column settings when updating the filter.

Expected Behavior

When you omit the optional filter field, the default filter from the column is used.

Why cannot we simply implement it?

Because the filter function is a setting of the column and the data source does not know anything about columns.

Possible solution?

Since the goal is to change the filter of the table it's probably best to add API to the table class which sets the filter query of the filter component which then trickles down to the DataSource.

@uap-universe uap-universe added the enhancement New feature or request label Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant