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

Set default values on Advanced Filter

Hi,

The advanced filter behavior for the SfDataGrid is very helpful but is there a way to set some default values? For example, I want the default value to be AND instead of OR, or in a Date filter the default selection is After and Before instead of Equals.

Thanks in advance.

3 Replies

JG Jai Ganesh S Syncfusion Team October 23, 2016 11:15 AM UTC

Hi David, 
 
We have analyzed your query. You can achieve your requirement to change the default as AND instead of OR and also showing the After and Before as default value in GridDateTimeColumn by customize the style for AdvancedFilterControl like below, 
<Style x:Key="popupstyleforOrderID" TargetType="Syncfusion:GridFilterControl"> 
            <Setter Property="FilterMode" Value="Both" /> 
            <Setter Property="AdvancedFilterStyle" Value="{StaticResource advancedfilterstyleforOrderID}" /> 
</Style> 
<Syncfusion:GridDateTimeColumn HeaderText="Delivery Date"  
                               FilterPopupStyle="{StaticResource popupstyleforOrderID}" 
                               MappingName="DeliveryDate"   
 
dataGrid.FilterItemsPopulated += DataGrid_FilterItemsPopulated; 
bool isChecked = false; 
private void DataGrid_FilterItemsPopulated(object sender, GridFilterItemsPopulatedEventArgs e) 
{ 
    var filterControl = (e.FilterControl as GridFilterControl); 
    var advancedFilterControlMember = filterControl.GetType().GetField("AdvancedFilterControl", BindingFlags.Instance | 
                    BindingFlags.NonPublic | 
                    BindingFlags.Public); 
    var advancedFilterControl = advancedFilterControlMember.GetValue(filterControl); 
    var IsORChecked = (advancedFilterControl as AdvancedFilterControl).IsORChecked; 
 
    if (!isChecked) 
    { 
        (advancedFilterControl as AdvancedFilterControl).IsORChecked = false; 
        isChecked = true; 
    } 
} 
 
Regards, 
Jai Ganesh S 



DG David García October 25, 2016 09:47 AM UTC

Thank you very much for the reply back and for the help with this issue as well for the example provided.


JG Jai Ganesh S Syncfusion Team October 26, 2016 03:49 AM UTC

Hi David,  
Thank you for the update. 
Please let us know if you need further assistance on this. 
Regards, 
Jai Ganesh S 


Loader.
Up arrow icon