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

Switch filter type

Hi,

I like to switch the filter type from filterbar to excel and back:

How can I do this?

Regards,
Carsten

7 Replies

VN Vignesh Natarajan Syncfusion Team April 1, 2019 04:09 AM UTC

Hi Carsten, 
 
Thanks for using Syncfusion products. 
 
Query: “I like to switch the filter type from filterbar to excel and back: 
 
From your query, we understand that you need to switch from filterbar to excel filter and vice versa. We have achieved your requirement by updating the filterSettings using setModel. Refer the below code example 
 
<div> 
        <input type="text" id="textFilter"> 
        <button id="buttonFilter" onClick="onFilterClick()"> 
          Filter 
        </button> 
        <button id="buttonFilterSwitch" onClick="onFilterSwitchClick()"> 
          Switch Type 
        </button> 
      </div> 
      <div id="Grid"> 
      </div> 
…………………………………………………………………………………………….. 
      <script> 
        var _filterType;       
        function onFilterSwitchClick (args) {         
          var gridObj = $("#Grid").ejGrid("instance");        
          if (gridObj.model.filterSettings.filterType == "filterbar" ) 
            _filterType = "excel"; 
          else 
            _filterType = "filterbar"; 
          gridObj.option({filterSettings: {filterType: _filterType}}) 
        } 
………………………………………………………………………………………………….. 
      </script> 
 
 
For your convenience, we have modified the provided sample which can be referred below  
 
 
Refer our API documentation for your reference 
 
 
We also would like to let you know about our next generation JavaScript product - Essential JS 2, in case if you are not aware of it. Essential JS 2 is fully re-written to be modular, responsive and lightweight.  
   
We suggest you consider our following product page for more details.  
 
   
Demo page for ej2 Grid 
  
 
Please get back to us if you have further queries.  
 
Regards, 
Vignesh Natarajan. 



CB Carsten Buchmann April 1, 2019 06:04 AM UTC

Thanks for your reply. This is what I wanted.

But it leads me to my next question: How can I make the filter function work with a "OR" condition instead of "AND"?




VN Vignesh Natarajan Syncfusion Team April 1, 2019 11:12 AM UTC

Hi Carsten, 
 
Thanks for the update 
 
Query: “How can I make the filter function work with a "OR" condition instead of "AND"? 
 
From your query, we understand that you need to change the filter bar message based on the filter predicate. But currently we do not have support to change the filter bar message and workaround is not also possible. So kindly use the excel filter to achieve your requirement (filter the records using or predicates). 
  
 
Regards, 
Vignesh Natarajan. 



CB Carsten Buchmann April 2, 2019 06:46 AM UTC

Hi,
I dont't want to change the message. I want to change the predicate from "AND" to "OR". As you can see in the example code I already set the predicate to "or" but with no effect.

But in the meantime I tested the search function which is working well in javascript but not with a MVC Controller Action and the URL Adapter. In this case the Search and Where property of the Data Manager object is null.

Kind regards,
Carsten


VN Vignesh Natarajan Syncfusion Team April 3, 2019 12:38 PM UTC

Hi Carsten, 
 
Query: “I dont't want to change the message. I want to change the predicate from "AND" to "OR". As you can see in the example code I already set the predicate to "or" but with no effect. 
 
In previously provided sample, ‘&&’ operator is used in filter message (in grid pager) to separate the two filtered columns with its value.It does not represent the predicate. So when filter button is clicked, Grid is filter with or predicate only. To ensure that it is working properly, kindly change the predicate to ‘and’ then ensure. Filtered values will be different. So values are filtered based on or predicate only. But in the filter message two strings are separated by ‘&&’. So we cannot change the filter message. So to overcome this we suggest you to use excel menu filter where you can filter the same column with or predicate.   
 
Query 2: I tested the search function which is working well in javascript but not with a MVC Controller Action and the URL Adapter. In this case the Search and Where property of the Data Manager object is null. 
 
From your query, we suspect that you are facing issue while performing searching in ejGrid with url adaptor. We are unable to reproduce the reported issue at our end. For your convenience we have created the sample.  
Also refer the below knowledge base document to perform server side operation in ejGrid.  
 
 
Output: 
 
 
Please refer the below link for the sample. 
 
After referring the sample still facing the issue, please get back to us with the following details. 
 
  1. Share the complete grid code example(both view and controller page).
  2. Share the video demonstration Or screenshot of the issue.
  3. If possible, reproduce the issue in provided sample and revert back to us.
 
Regards, 
Vignesh Natarajan. 
 



CB Carsten Buchmann April 10, 2019 07:01 AM UTC

Query 1: the problem is to switch to Excel Filter. Once switched to Excel Filter the predicate is always "AND". I will work around this problem.

Query 2: I didn't use the property "AllowSearching".

Thanks for your support.


VN Vignesh Natarajan Syncfusion Team April 11, 2019 07:03 AM UTC

Hi Carsten,  
 
Thanks for the update.  
 
AllowSearching must be enabled in ejGrid to perform search operation in Grid in server side.We are glad to know that your query has been resolved.  
 
Please get back to us if you have further queries. 
 
Regards, 
Vignesh Natarajan. 


Loader.
Live Chat Icon For mobile
Up arrow icon