We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Filtering is not working

5 Replies

PS Pavithra Subramaniyam Syncfusion Team September 3, 2019 07:22 AM UTC

Hi kenan, 
Thanks for contacting Syncfusion support. 
In custom data binding with Async pipe, we need to generate the filter query from the state passes to the service. So that the filter action will be done in the service. We have prepared a simple sample based on your requirement. Please refer to the below code example and sample link.  
export class OrderService {  
    .   .   .  
    public execute(state: DataStateChangeEventArgs): Promise<DataResult> {  
        return this.getData(state);  
    private getData(state: DataStateChangeEventArgs): Promise<DataResult> {  
        const pageQuery = `$skip=${state.skip}&$top=${state.take}`;  
        let sortQuery: string = '';  
        let filterQuery: String = '';  
        if (state.where) {  // here you can prepare the filter query  
            filterQuery = `&$filter=` + state.where.map((obj:any) => {  
                return (obj).predicates.map((predicate:any) => {  
                    return predicate.operator === 'equal' ? `${predicate.field} eq ${predicate.value}` :                     `${predicate.operator}(tolower(${predicate.field}),'${predicate.value}')`;  
                }).reverse().join(' and ');  
        this.ajax.url = `${this.BASE_URL}?${pageQuery}${sortQuery}${filterQuery}&$inlinecount=allpages&$format=json`;  
        return this.ajax.send().then((response: any) => {  
            const data: any = JSON.parse(response);  
            return {  
                count:  parseInt(getValue('d.__count', data), 10),  
                result: getValue('d.results', data)  
Please get back to us if you need any further assistance on this. 
Pavithra S. 

KD kenan dogan September 5, 2019 11:26 AM UTC

Thank you. So, How do I use checkbox filter?

PS Pavithra Subramaniyam Syncfusion Team September 6, 2019 08:33 AM UTC

Hi kenan, 
For Custom Binding with Async pipe, the grid actions query should be generated in service by manually as per your requirement. For CheckBox or Excel filter you need to return the dataSource from the server based on some condition for the request to populate the Filter dialog with checkbox. Please refer to the below code example for more information. 
import { Injectable } from '@angular/core'; 
export class OrdersService extends Subject<DataStateChangeEventArgs> { 
  public getData(state: DataStateChangeEventArgs): Observable<DataStateChangeEventArgs> { 
      .    .   . 
     if (state.where) {  
 // here you can prepare the filter query as per your requirment 
    return this.http 
      .pipe(map((response: any) => response.json())) 
      .pipe(map((response: any) => { 
        return state.dataSource === undefined ? (<DataResult>{ 
          result: response['value'], 
          count: parseInt(response['@odata.count'], 10), 
        }) : response['value']; 
      .pipe(map((data: any) => data)); 
public dataStateChange(state: DataStateChangeEventArgs): void { 
    if ((<any>state.action).requestType === 'filterchoicerequest' ||(<any>state.action).requestType=== 'filtersearchbegin') { 
      this.service.getData(state).subscribe((e) => state.dataSource(e)); 
    } else { 
Pavithra S 

KD kenan dogan September 11, 2019 11:36 AM UTC

Thank you for support.

TS Thavasianand Sankaranarayanan Syncfusion Team September 12, 2019 06:35 AM UTC

Hi Kenan, 
Thanks for your update. 
We are happy that the problem has been resolved at your end. 
Thavasianand S.  

Live Chat Icon For mobile
Up arrow icon