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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Set default values on Advanced Filter

Thread ID:

Created:

Updated:

Platform:

Replies:

126994 Oct 20,2016 10:16 AM UTC Oct 26,2016 03:49 AM UTC WPF 3
loading
Tags: SfDataGrid
David García
Asked On October 20, 2016 10:16 AM UTC

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.

Jai Ganesh S [Syncfusion]
Replied On 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 


David García
Replied On 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.

Jai Ganesh S [Syncfusion]
Replied On 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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;