Skip to content

Infragistics Community Forum / Web / Ignite UI for Angular / How to do a custom filtering on the igx-tree Grid

How to do a custom filtering on the igx-tree Grid

New Discussion
Manikanta Vundavalli
Manikanta Vundavalli asked on Apr 15, 2022 12:25 PM

Hi,

I have a scenario where in the tree grid I have a nested grouping of rows up to three levels as shown below.

A

B

C

and inside of the filtering options I have the Value A and when I apply column filtering on the first column with option as A I should be able to filter all of its nested child rows B and C as well.

Thanks,

Mani

Sign In to post a reply

Replies

  • 0
    Viktor Kombov
    Viktor Kombov answered on Sep 28, 2021 5:26 PM

    Hello Mani,

    At this point we do not provide an out of the box option for filtering all of the children of the matching records. What I can suggest for achieving your requirement is using a custom filter strategy. You can do this by setting filterStrategy input of the Tree Grid to your own custom strategy in order to display the matching records and all of their children:

    HTML

    
    ...
    
    

    TYPESCRIPT

    …
    export class TreeGridFormattedFilteringStrategyComponent implements OnInit {
        ...
        public customFilterStrategy = new CustomFilteringStrategy();
        ...
    }
    ...
    export class CustomFilteringStrategy extends TreeGridFilteringStrategy {
        public filter(data: ITreeGridRecord[], expressionsTree: IFilteringExpressionsTree,
            advancedExpressionsTree?: IFilteringExpressionsTree, grid?: GridType): ITreeGridRecord[] {
            return this.customFilterImpl(data, expressionsTree, advancedExpressionsTree, undefined, grid);
        }
    
        private customFilterImpl(data: ITreeGridRecord[], expressionsTree: IFilteringExpressionsTree,
            advancedExpressionsTree: IFilteringExpressionsTree, parent: ITreeGridRecord, grid?: GridType): ITreeGridRecord[] {
            let rec: ITreeGridRecord;
            let recWithAllOfItsChildren: ITreeGridRecord;
            const res: ITreeGridRecord[] = [];
            ...
            for (i = 0; i < data.lenght; i++) {
                ...
                recWithAllOfItsChildren = DataUtil.cloneTreeGridRecord(rec);
                ...
                if (this.matchRecord(rec, expressionsTree, grid) && this.matchRecord(rec, advancedExpressionsTree, grid)) {
                    res.push(recWithAllOfItsChildren);
                }
                ...
            }
            return res;
        }
        ...
    }

    I created a small sample illustrating my suggestion, which you can find here. Please keep in mind that this suggestion is a workaround and it is not fully tested, so it is possible to encounter any edge cases for some scenarios. Please test it on your side and let me know whether you find it helpful.

    Please let me know if you have any further questions and concerns.

    Regards,
    Viktor Kombov
    Entry Level Software Developer
    Infragistics, Inc.

    • 0
      madhukar avunoori
      madhukar avunoori answered on Apr 15, 2022 12:25 PM

      Dear Viktor,  Row should be deleted instead of disable from the below link. I am using text filter  on Product Name -> doesn't contain -> Foods 

      https://stackblitz.com/edit/github-qmenlj?file=src%2Fapp%2Ftree-grid-excel-style-filtering-sample-1%2Ftree-grid-excel-style-filtering-sample-1.component.html 

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Manikanta Vundavalli
Favorites
0
Replies
2
Created On
Apr 15, 2022
Last Post
3 years, 10 months ago

Suggested Discussions

Created on

Apr 15, 2022 12:25 PM

Last activity on

Feb 23, 2026 6:01 PM