【问题标题】:Tree filtration in ag-gridag-grid 中的树过滤
【发布时间】:2021-08-06 16:22:00
【问题描述】:

我们将企业 ag-grid 从 16.0.1 升级到 25.1.0。 因此,树过滤的算法发生了变化。

之前它不包括不匹配的子代,但现在它显示匹配父代的所有子代。

例如,如果我们有一个树数据:

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

并使用设置:

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

它们显示为

- One
  - Twenty
  - Thirty
- Two

按“One”过滤后,它现在看起来像

- One
  - Twenty
  - Thirty

- 它包括“One”的所有子代:“Twenty”、“Thirty”不匹配过滤。 但在 16.0.1 版本中,此结果为

- One

- 它只包括匹配的项目。 我们在过滤中需要这种“老式”算法,但我没有找到如何设置它。 我试过了

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

但它不起作用,因为匹配父级的子级甚至没有进入这个函数。它只在“一”和“二”父母上运行。

如果我想排除匹配父级的不匹配子级,如何设置此树过滤?

【问题讨论】:

    标签: ag-grid ag-grid-react


    【解决方案1】:

    Ag Grid 支持小组帮助了我,非常感谢!
    也许他们的回答对其他人有用。
    我们应该使用

    excludeChildrenWhenTreeDataFiltering: true,
    

    如中所述 https://www.ag-grid.com/javascript-grid/tree-data/#tree-data-filtering

    【讨论】:

    • 非常感谢:)
    猜你喜欢
    • 1970-01-01
    • 2023-03-27
    • 2020-06-12
    • 2019-07-28
    • 2016-06-15
    • 2016-09-26
    • 2019-04-20
    • 2022-10-25
    • 2020-10-04
    相关资源
    最近更新 更多