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

IgxTreeGrid: display only filtered records #9923

Closed
viktorkombov opened this issue Jul 26, 2021 · 1 comment · Fixed by #10077
Closed

IgxTreeGrid: display only filtered records #9923

viktorkombov opened this issue Jul 26, 2021 · 1 comment · Fixed by #10077
Assignees
Labels
filtering grid: tree-grid 🧰 feature-request ✅ status: resolved Applies to issues that have pending PRs resolving them, or PRs that have already merged.

Comments

@viktorkombov
Copy link
Contributor

Is your feature request related to a problem? Please describe.

When filtering condition is applied to a column in IgxTreeGrid not only the records that meet specified criteria are displayed but also their parents.

tree-grid-filtering-strategy1

Describe the solution you'd like

I would like to be provided with an option for displaying only the records that meet specified criteria withtout their parents.

@viktorkombov
Copy link
Contributor Author

As a workaround the requirement can be achieved with a custom filtering strategy:

TYPESCRIPT
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): TreeGridRecord[] {
        let rec: ITreeGridRecord;
        const res: ITreeGridRecord[] = [];
        …
        if (this.matchRecord(rec, expressionsTree, grid) && this.matchRecord(rec, advancedExpressionsTree, grid)) {
            res.push(rec);
        } else if (rec.children && rec.children.length > 0) {
            rec = this.setCorrectLevelToFilteredRecords(rec);
            res.push(...rec.children);
        }
        ….
        return res;
    }
    …
}

This is a sample that implements the above approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
filtering grid: tree-grid 🧰 feature-request ✅ status: resolved Applies to issues that have pending PRs resolving them, or PRs that have already merged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants