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

Multiple filters on one column

Hello,

Is it possible to apply multiple filters onto the same column. Like this

$("#SearchGrid").ejGrid("filterColumn", [{ field: "Type", operator: "contains", value: "B", predicate: "and", matchcase: false }, { field: "Type", operator: "contains", value: "B", predicate: "and", matchcase: false }]);

What I am attempting is to show rows of "Type" that contain "A" and also contain "B". 

5 Replies

MP Manivannan Padmanaban Syncfusion Team July 12, 2019 11:09 AM UTC

Hi Matthew, 

We have achieved your requirement kindly refer the below code example, 

 
    <button id="btn" onclick="Filter()"> 
        Click here to filter 
    </button> 
………………….. 
    <div id="Grid"></div> 
    <script type="text/javascript"> 
        $(function () { 
……………………… 
            $("#Grid").ejGrid({ 
……………………………….. 
                allowFiltering: true, 
                filterSettings: { filterType: "excel" }, 
                columns: [ 
…………………………………………….. 
                ] 
            }); 
        }); 
 
        function Filter() { 
            var gridObj = $("#Grid").ejGrid("instance"); // create the grid instance using grid ID. 
            gridObj.filterColumn([ 
                { field: "CustomerID", operator: "contains", value: 'o', predicate: "and", matchcase: false }, 
                { field: "CustomerID", operator: "contains", value: 'u', predicate: "and", matchcase: false }, 
            ]) 
        } 
………………………….. 
    </script> 
</body> 
</html> 


Refer the below link for sample. 

Regards, 
Manivannan Padmanaban. 



MA Matthew July 12, 2019 06:13 PM UTC

Thank you, the code helped clarify the method. Also the problem was that during initializing my grid I had

filterSettings: { filterType: "menu" }

when what was required was,

filterSettings: { filterType: "excel" }



MP Manivannan Padmanaban Syncfusion Team July 15, 2019 08:53 AM UTC

Hi Matthew, 

Thanks for the update. 

You can use the same solution for the filter type menu as well. Excel filter is work based on “and” predicate where else menu is work based on “or” predicate. For example, in the shared example we have filtered the CustomerID column which contains the value as “o” and “u”. In excel filter, due to “and” operation is shows the result as the value which contains both “o” and “u”. But the menu filter, due to “or” operation first it filter the values which contains “o” and later it filter the value which contains “u” which is the default behavior.  

Kindly get back to us, if you need further assistance. 

Regards, 
Manivannan Padmanaban. 



MA Matthew July 15, 2019 02:09 PM UTC

Thank you for clearing that up Manivannan, and for your assistance.



MP Manivannan Padmanaban Syncfusion Team July 16, 2019 04:06 AM UTC

Hi Matthew, 

Thanks for the update. 

Kindly get back to us, if you need further assistance. 

Regards, 
Manivannan Padmanaban. 


Loader.
Live Chat Icon For mobile
Up arrow icon