0

I have a tree structure data angular-slickgrid with parent-child relationship. Whenever I try to filter parent records by typing some values in search box, parent records get filtered but without all of its child records.

I can still see +/- icon in front of parent records but clicking on it brings only those child records that match the search value.

I want all of the child records of filtered parent record to get displayed when I expand the parent record irrespective of searched value. Any possible solution to achieve this?

Apoorva Chikara
  • 8,277
  • 3
  • 20
  • 35
Anant Shekhar
  • 101
  • 1
  • 5
  • It's the usual behaviour of slickgrid I guess. Check this. https://ghiscoding.github.io/Angular-Slickgrid/#/tree-data-parent-child – Dananjaya Sep 14 '21 at 10:47
  • Ideally, this shouldn't be the usual behaviour, right? Anyways, I can try to implement my own logic but I have a problem. I don't know what method sets the filtered data in grid when we filter any record. If I'm aware of that method, I can try to filter the child records also based on filtered parent records and set them. – Anant Shekhar Sep 14 '21 at 12:11
  • that's the default behavior that I wanted and my users expect, I won't change that anytime soon, I know Ag-Grid have this flag `excludeChildrenWhenTreeDataFiltering` to handle that but I don't have that in my lib and I don't have time either to add that feature. The best would be for you to contribute, the issue should be in this [function](https://github.com/ghiscoding/slickgrid-universal/blob/master/packages/common/src/services/filter.service.ts#L528) if you have time to spend on recursive functions... or pay thousand of dollars a year for Ag-Grid... – ghiscoding Sep 14 '21 at 12:44
  • This is now available as described in the answer, however I must say... as a reminder, this is an Open Source project and everyone is welcome to contribute (even as small as fixing a typo in a Wiki is welcome). We all gain from contributions, I strongly encourage you to contribute back – ghiscoding Sep 29 '21 at 21:53

1 Answers1

0

There is now a new Tree Data option excludeChildrenWhenFilteringTree (defaults to false), the new default of Tree Data filtering will now include children (same as the OP question) when the parent item passes its filter criteria, so please note that this is different compare to older version where it would not include children and if you still want the same behavior as before then you could use this new flag excludeChildrenWhenFilteringTree: true, which as the name suggest, will exclude children (unless they match the filter).

So this answer is only valid if you install the newer version v3.2.0+ of Angular-Slickgrid, check the Release section and the updated Tree Data (filtering options) - Wiki.

ghiscoding
  • 12,308
  • 6
  • 69
  • 112