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

Using LocalDataSource setFilter with andOperator === false #1135

Open
richardruge opened this issue Feb 25, 2020 · 0 comments
Open

Using LocalDataSource setFilter with andOperator === false #1135

richardruge opened this issue Feb 25, 2020 · 0 comments

Comments

@richardruge
Copy link

richardruge commented Feb 25, 2020

Using LocalDataSource.setFilter() with andOperator === false AND with those columns' filter text box displaying; the andOperator is always overridden to be true.

Example: once your data is loaded, you would like to set the filter to show those records where either of two column searches is found; i.e.:
this.dataList.setFilter([{ field: "fieldA", search: "test"}, { field: "fieldB", search: "test"}], false);

You also have table settings as follows:
...columns: { fieldA: { title: "Field A", filter: true}, fieldB: { title: "Field B", filter: true} }

You can monitor the change updates via:
this.projects.onChanged().subscribe(async (change) => { if (change.action === "filter") { ... }

The change.filter.andOperator first comes into the above anonymous function as false and then true. This defeats the original andOperator === false.

With further research, I found ng2-smart-table calls FormsControl.setValue as:
this.inputControl.setValue(this.query);

...and this triggers an onChange event on the filtering text input control. This causes the second unexpected on-change event on the LocalDataSource with the andOperator set to true.

Normally, when a user manually updates the filter fields, it is expected that the filters would be AND'd together. But in this case, I am trying to filter on either fields by trying to OR the field searched together.

@richardruge richardruge changed the title Using LocalDataSource setFilter with andOperator == false Using LocalDataSource setFilter with andOperator === false Feb 25, 2020
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

No branches or pull requests

1 participant