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

clearFiltering throws Error

Hi

When tinkering with some filtering on a grid I observed the following.

If I use the clearFiltering Method on a column that was not filtered before it throws an error when the filterType is set to 'excel'. It works if the filterType is set to 'filter bar'. Is this a bug with the 'excel' grid?

If this is a wanted feature is there a straightforward way to find out if a filter is set for a given column? I don’t think it is straightforward to get all filters from *.widget.model.filterSettings.filteredColumns and run through all entries looking for the value of ‘field’.

Regards

Bernd

 


1 Reply

MS Mani Sankar Durai Syncfusion Team September 18, 2017 10:59 AM UTC

Hi Bernd, 

Thanks for contacting Syncfusion support. 

We have analyzed your query and we are able to reproduce the reported issue. We have confirmed that the issue “Script error throws when clearFiltering without filtering the columns” is a defect, and we have logged a defect report. The fix for this issue will be included in our Volume 3 SP2, 2017 release expected to be out by the month of September, 2017. 
Until then we suggest you to use the below workaround solution which helps to solve this issue.  
Refer the code example 
... 
                <button id="btn" onclick="myFunc()">Clear filter</button> 
                <div id="Grid"></div> 
... 
<script type="text/javascript"> 
   
    $(function () { 
        $("#Grid").ejGrid({ 
            dataSource: window.gridData, 
... 
            allowFiltering: true, 
            filterSettings:{filterType:"excel"}, 
            columns: [ 
                ...           
        }); 
    }); 
 
    </script> 
    <script> 
        function myFunc(){ 
            var grid = $('#Grid').ejGrid("instance"); 
            if (grid.filterColumnCollection.length) {  //check the condition if the column is filtered before calling clearFiltering method 
                grid.clearFiltering(grid.filterColumnCollection[0].field); 
            } 
        } 
    </script> 

We have prepared a simple sample link in JSPlayground that can be available under the below link. 

Regards, 
Manisankar Durai. 



Loader.
Live Chat Icon For mobile
Up arrow icon