简体   繁体   中英

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?

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM