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
close icon

how to set two filters of the same column programmatically

Good evening.


I would like to set two filters of the same column programmatically. I could use the "filterColumn" method.  

This method works properly when there are two filters of different columns. However, if there are two filters of the same column, it only gets the last filter.


I will be waiting for your reply, thank you in advance.

Regards, Luis Carlos.



1 Reply

VN Vignesh Natarajan Syncfusion Team March 7, 2019 04:39 AM UTC

Hi Luis, 
 
Thanks for contacting Syncfusion support.  
 
Query: “I would like to set two filters of the same column programmatically” 
 
From your query, we understand that you need to filter the same column with two values. We suggest you to achieve your requirement using filterSettings API and refreshContent() method of ejGrid. Refer the below code example 
 
<ej-grid id="FlatGrid" allow-paging="true" datasource="ViewBag.dataSource" allow-filtering="true"> 
    <e-filter-settings filter-type="Excel" />     
    <e-columns> 
        ……………………………………………………………. 
    </e-columns> 
</ej-grid> 
 
<script type="text/javascript"> 
    function onClick() { // external button click event 
        var Obj = $("#FlatGrid").ejGrid("instance"); 
        Obj.model.filterSettings.filteredColumns.push({ field: "ShipCity", operator: "startswith", value: "Be", predicate: "or", matchCase: true }); 
        Obj.model.filterSettings.filteredColumns.push({ field: "ShipCity", operator: "startswith", value: "Ts", predicate: "or", matchCase: true }); 
        Obj.refreshContent(); 
    } 
</script> 
  
 
Refer our API documentation for your reference 
 
 
 
Please get back to us if you have further queries. 
 
Regards, 
Vignesh Natarajan. 


Loader.
Live Chat Icon For mobile
Up arrow icon