Hi Kivanc Yilmaz,
Your requirement to customize the isEnable property in PART_OkButton of the filter
toggle button in SfDataGrid by customizing the FilterItemsPopulating event.
Refer to the below code snippet,
//Event subscription
this.AssociatedObject.FilterItemsPopulating
+= OnFilterItemsPopulating;
//Event customization
private void OnFilterItemsPopulating(object sender, GridFilterItemsPopulatingEventArgs e)
{
if (e.FilterControl != null)
{
//Here gets the PART_OkButton by using reflection in SfDataGrid
var okButton =
(Button)e.FilterControl.GetType().GetField("OkButton", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(e.FilterControl);
//Here get the SfDataGrid
var sfDataGrid = sender as SfDataGrid;
if(sfDataGrid != null && okButton != null && sfDataGrid.View != null && sfDataGrid.View.Records != null)
{
//here checks the condition based on your scenario
if(sfDataGrid.View.Records.Count == 0)
{
//Here disable the PART_OkButton of filtertogglebutton
okButton.IsEnabled = false;
}
else
//Here enables the PART_OkButton of filtertogglebutton
okButton.IsEnabled = true;
}
}
}
|
UG Link: https://help.syncfusion.com/wpf/datagrid/filtering#filteritemspopulating-event
Find the sample in the attachment.
Regards,
Vijayarasan S
If this post is helpful, please consider Accepting it as the
solution so that other members can locate it more quickly.
Attachment:
Sample_9556630c.zip