rashidali
rashidali

Reputation: 330

Get filter values in kendo grid ui

I have kendo grid as

<kendo-grid
    [data]="gridData"
    [pageSize]="state.take"
    [skip]="state.skip"
    [sort]="state.sort"
    [filter]="state.filter"
    filterable="menu"
    (dataStateChange)="dataStateChange($event)"
>

and in component.ts file

    public dataStateChange(state: DataStateChangeEvent): void {
    this.state = state;
    // get filter values here 

}

I want to get the filter values and field names in above function and pass them to api for server side filtering but unable to extract the values from state.

Is there any way to extract fields and values from state object?

Upvotes: 1

Views: 3577

Answers (1)

Nail Achmedzhanov
Nail Achmedzhanov

Reputation: 1494

Primitive variant

import { isCompositeFilterDescriptor } from '@progress/kendo-data-query';
....
const filterValues = state.filter.filters.map(f => isCompositeFilterDescriptor(f) ? f.filters :[f] ).reduce((p,n) => p.concat(n), []);

But you should check "logic" field, see https://www.telerik.com/kendo-angular-ui/components/dataquery/api/CompositeFilterDescriptor/

Upvotes: 2

Related Questions