1
votes

We upgraded enterprise ag-grid from 16.0.1 to 25.1.0. As a result, the algorithm of tree filtering has been changed.

Before it didn't include not matching children, but now it shows ALL the children of the matching parent.

For example, if we have a tree data:

[
    {
      path: ['One'],
    },
    {
      path: ['One', 'Twenty'],
    },
    {
      path: ['One', 'Thirty'],
    },
    {
      path: ['Two'],
    },
  ]

And use the settings:

autoGroupColumnDef: {
  filter: 'agTextColumnFilter',
  floatingFilter: true
},
treeData: true,
getDataPath: ({ path }) => path,

They display as

- One
  - Twenty
  - Thirty
- Two

After filtering by "One" it looks now as

- One
  - Twenty
  - Thirty

- it includes all the children of "One": "Twenty", "Thirty" that don't match filtering. But in version 16.0.1 this result was as

- One

- it included only matching items. We need in our filtrations exactly this "old-fashioned" algorithm, but I didn't find how to set it. I tried

filterValueGetter: ({ data: { path } }) => path[path.length - 1]

but it doesn't work, because the children of the matching parent don't even get into this function. It runs only on "One" and "Two" parents.

How can I set this tree filtration if I want to exclude not matching children of the matching parent?

1

1 Answers

1
votes

Ag Grid support group helped me, thank you so much!
Maybe their answer would be useful for someone else.
We should use

excludeChildrenWhenTreeDataFiltering: true,

As described in https://www.ag-grid.com/javascript-grid/tree-data/#tree-data-filtering