Hello,
my DataGrid is pretty straight forward, it's a Grid with Transcational Data, binded as ObservableCollection<ITransactionViewer>.
<StackPanel Grid.Row="0" Orientation="Horizontal">
<CheckBox x:Name="FilterBox" Click="Filter_Click" IsChecked="False" Content="{x:Static res:Strings.Filter}" HorizontalAlignment="Right"/>
</StackPanel>
<syncfusion:SfDataGrid x:Name="TransactionsGrid" Grid.Row="1" ColumnSizer="Auto" AllowResizingColumns="True" SelectionUnit="Cell" AutoGenerateColumns="False" ItemsSource="{Binding Transactions}" Margin="1">
<syncfusion:SfDataGrid.Columns>
<syncfusion:GridNumericColumn TextAlignment="Center" MappingName="TransactionID" HeaderText="ID" NumberDecimalDigits="0"/>
<syncfusion:GridTextColumn TextAlignment="Center" MappingName="Wallet"/>
<syncfusion:GridDateTimeColumn TextAlignment="Center" Pattern="SortableDateTime" MappingName="TransactionTime" HeaderText="{x:Static res:Strings.TransactionTime}"/>
<syncfusion:GridTextColumn TextAlignment="Center" MappingName="TransactionType" HeaderText="{x:Static res:Strings.Type}"/>
<syncfusion:GridNumericColumn TextAlignment="Center" MappingName="AmountStart" HeaderText="{x:Static res:Strings.Amount}"/>
<syncfusion:GridTextColumn TextAlignment="Center" MappingName="AssetStart" HeaderText="{x:Static res:Strings.Asset}"/>
<syncfusion:GridTextColumn TextAlignment="Center" MappingName="LocationStart" HeaderText="{x:Static res:Strings.On}"/>
<syncfusion:GridNumericColumn TextAlignment="Center" MappingName="AmountDestination" HeaderText="{x:Static res:Strings.Amount}"/>
<syncfusion:GridTextColumn TextAlignment="Center" MappingName="AssetDestination" HeaderText="{x:Static res:Strings.Asset}"/>
<syncfusion:GridTextColumn TextAlignment="Center" MappingName="LocationDestination" HeaderText="{x:Static res:Strings.On}"/>
<syncfusion:GridNumericColumn TextAlignment="Center" MappingName="TransactionValue" HeaderText="{x:Static res:Strings.Value}" NumberDecimalDigits="2"/>
<syncfusion:GridNumericColumn TextAlignment="Center" MappingName="FeeAmount" HeaderText="{x:Static res:Strings.Amount}"/>
<syncfusion:GridTextColumn TextAlignment="Center" MappingName="FeeAsset" HeaderText="{x:Static res:Strings.Asset}"/>
<syncfusion:GridNumericColumn TextAlignment="Center" MappingName="FeeValue" HeaderText="{x:Static res:Strings.FeeValue}" NumberDecimalDigits="2"/>
</syncfusion:SfDataGrid.Columns>
<syncfusion:SfDataGrid.StackedHeaderRows>
<syncfusion:StackedHeaderRow>
<syncfusion:StackedHeaderRow.StackedColumns>
<syncfusion:StackedColumn ChildColumns="AmountStart,AssetStart,LocationStart" HeaderText="{x:Static res:Strings.From}" MappingName="from"/>
<syncfusion:StackedColumn ChildColumns="AmountDestination,AssetDestination,LocationDestination" HeaderText="{x:Static res:Strings.To}" MappingName="to"/>
<syncfusion:StackedColumn ChildColumns="FeeAmount,FeeAsset,FeeValue" HeaderText="{x:Static res:Strings.Fee}" MappingName="fees"/>
</syncfusion:StackedHeaderRow.StackedColumns>
</syncfusion:StackedHeaderRow>
</syncfusion:SfDataGrid.StackedHeaderRows>
</syncfusion:SfDataGrid>
As you can see, there is a checkbox, which function is to activate or deactivate a specific filter (filter all rows, that have Empty Cells (strings) or a value of 0 or -1 (numeric).
public bool FilterRows(object o)
{
var item = o as ITransactionViewer;
if (item != null)
{
if (string.IsNullOrWhiteSpace(item.AssetStart)) return true;
if (string.IsNullOrWhiteSpace(item.AssetDestination)) return true;
if (string.IsNullOrWhiteSpace(item.FeeAsset)) return true;
if (string.IsNullOrWhiteSpace(item.LocationStart)) return true;
if (string.IsNullOrWhiteSpace(item.LocationDestination)) return true;
if (item.AmountStart == 0.0m) return true;
if (item.AmountDestination == 0.0m) return true;
if (item.FeeAmount == 0.0m) return true;
if (item.TransactionValue == 0.0m || item.TransactionValue == -1.0m) return true;
if (item.FeeValue == -1.0m) return true;
}
return false;
}
private void Filter_Click(object sender, System.Windows.RoutedEventArgs e)
{
if (FilterBox.IsChecked == true)
{
TransactionsGrid.SortColumnDescriptions.Clear();
TransactionsGrid.View.Filter = FilterRows;
TransactionsGrid.View.RefreshFilter();
}
else
{
TransactionsGrid.SortColumnDescriptions.Clear();
TransactionsGrid.ClearFilters();
}
}
Activating the filter is working fine and the result is as intended. However when I uncheck the CheckBox, the ClearFilters() method is called, but the filter is not removed.
Any help?
Greetings
Alex
Hi Alexander,
We have investigated the reported issue and have successfully replicated it on our end. In order to further diagnose the problem, we need to examine the issue at the source level. As a result, we require some time to validate and will provide an update on or before September 28, 2023.
Regards,
Santhosh.G
Alexander,
I
apologize for the inconvenience, but we need to examine the issue at the source
level. Consequently, we will need some time to validate it and will provide an
update on or before October 03, 2023.
Alexander,
Kindly be informed that our goal is to clear the filtered
records. Initially, we use a view filter to filter the records, and then we
want to clear the filtered records using the "ClearFilters" method.
In this view filter process, we do not use the "ClearFilters" method
because the implementation of the"ClearFilters"method is based on
filter predicates. Therefore, we use the "ClearFilters" method in the
view filter process, which does not clear the records.
Suppose we are using column-based filter predicates for the filtering process. In that case, we use the "ClearFilters" method to clear the filtered records.
We have decided to clear the view filter records by nullifying the view filter value and then refreshing the view using the RefreshFilter method. For your reference, please refer the attached code snippet.
private void Button_Click_1(object sender, RoutedEventArgs e) {
dataGrid.View.Filter = null;
dataGrid.View.RefreshFilter(); } |
Also, let us know if you need any other assistance. We will be happy to assist you.