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

How to get Filter String when filter changed for Excel Filter

Is there a built in way to get the filter string for a GridGroupingControl using an GridExcelFilter when filtering either by check boxes OR custom filter?

This is the string I expect for a multi column filter
([col1name] in ('val1-1', 'val1-2', 'val1-3', 'val1-4')) AND ([col2name] in ('val2-1', 'val2-2', 'val2-3', 'val2-4')) AND ([col3] LIKE '%val3%')

What I'm also noticing is that the check box filter and custom filters do not raise the same events. Is there a single event for any type of filter?

3 Replies

AR Arulpriya Ramalingam Syncfusion Team December 1, 2017 09:35 AM UTC

Hi David,   
   
Thanks for contacting Syncfusion support.   
   
As per the GridGroupingControl architecture, the RecordFilteres.Changed event will trigger for the RecordFilter and the RecordFiltersItemChanged event will trigger for the ExcelFilter(CheckBox filter). We regret to let you know that the GridGroupingControl does not have a common event to trigger for both filters (i.e. RecordFilter and ExcelFilter) and to retrieve the filter expression. Moreover, you can retrieve the filtered records from the FilteredRecords collection. Please refer to the below KB links to retrieve the filtered records and to know more about the events of filtering,   
   
   
   
Regards,   
Arulpriya   



DA David December 5, 2017 04:55 PM UTC

My original question wasn't answered - Is there a built in way to get the filter string for a GridGroupingControl using an GridExcelFilter when filtering either by check boxes OR custom filter?


AR Arulpriya Ramalingam Syncfusion Team December 6, 2017 05:04 PM UTC

Hi David, 
 
Thanks for your update. 
 
We have analyzed your requirement and regret to let you know that the GridGroupingControl does not have the support to get the FilterString/Expression when the records are filtered by CheckBox options of GridExcelFilter. However, the RecordFiltersChanged event will trigger for the CustomFilters on GridExcelFilter and the Expression of filtered records can be retrieved from the RecordFilters collection by using the Expression property. Please refer to the below code and sample, 
 
Code example 
 
//Event Triggering 
this.gridGroupingControl1.TableDescriptor.RecordFilters.Changed += RecordFilters_Changed; 
 
//Event Customization 
private void RecordFilters_Changed(object sender, Syncfusion.Collections.ListPropertyChangedEventArgs e) 
{ 
    if (this.gridGroupingControl1.TableDescriptor.RecordFilters.Count > 0) 
    { 
        foreach (RecordFilterDescriptor recordFilter in gridGroupingControl1.TableDescriptor.RecordFilters) 
       { 
            string expression = recordFilter.Expression; 
            MessageBox.Show(expression); 
        } 
    } 
} 
 
 
Please let us know if you have any other queries. 
 
Regards, 
Arulpriya 


Loader.
Live Chat Icon For mobile
Up arrow icon