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

Grid throws if passed an expressionTree with a field name that does not exist in Grid. #15563

Closed
hanastasov opened this issue Mar 21, 2025 · 1 comment · Fixed by #15564 or #15568
Closed

Comments

@hanastasov
Copy link
Contributor

hanastasov commented Mar 21, 2025

Description

Grid supports accepting a FilteringExpressionsTree with missing logic function. The grid will recreate the logic based on the field it refers to.

However, if such field does not exist in the grid data, condition logic will not be recreated (Expected). Still, the grid will try to call condigion.logic without verifying it does exist

  • igniteui-angular version: 19.1.4

Steps to reproduce

  1. Add grid

  2. Pass the following filteringExpressionsTree:
    grid.advancedFilteringExpressionsTree = JSON.parse('{"filteringOperands":[{"fieldName":"Missing","condition":{"name":"notEmpty","isUnary":true,"iconName":"filter_not_empty"},"conditionName":"notEmpty","ignoreCase":true,"searchVal":null,"searchTree":null}],"operator":0,"returnFields":[],"type":1}')

  3. Grid throws:
    cond.logic is not a function

Result

the filtering strategy should return false when trying to find a value in a field, which does not exist. Should try to call the condigion logic function to check a value.

Image

Expected result

Grid should appear empty, because for every record, false would have been returned by the filtering strategy
AdvancedFilteringDialog should still display the filtering expression:

Image

@hanastasov
Copy link
Contributor Author

hanastasov commented Mar 21, 2025

Alternatives considered:
One suggestion was for the grid to throw an error if it is unable to recreate a condition, as in this case. This would signal to the developer that the filteringExpressionTree contains a field that does not exist in the grid.

However, I believe that not throwing an error and instead returning an expression with an empty condition is the better approach for several reasons:

  • It allows the application to continue running. The grid will be displayed empty, making it clear to the user what filtering expressions have been applied. This behavior aligns with the expected outcome—when a filtering expression does not match any existing records, the grid naturally returns zero results.
  • The filteringExpressionsTree and data should be treated as dynamic. Consider a scenario where an application displays data with a certain filter applied. The user retrieves data based on a condition, the data is fetched, and the filter is applied. If the user then fetches new data based on a different condition, the filtering remains unchanged, but the underlying data may be completely different. In such cases, throwing an error would be an unexpected and disruptive behavior.
  • The grid supports the autoGenerate feature, which accommodates scenarios where each new data assignment may have a different structure. If all other grid features are designed to work dynamically, it would be inconsistent for Filtering to throw, if a certain field does not exist in grid data.

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