A DataGrid control that inherits from the base DataGrid control class and override some methods to implement filters
for each column like Excel, in automatic or custom generation.
Translation of labels and formatting of dates in the following languages: Chinese, Dutch, English, French, German, Italian, Polish, Russian, Spanish.
The translations are from google translate, if you find any errors or want to add other languages, please let me know.
The Nuget package is available here.
To understand how the filter works, you can consult the article posted on CodeProject.
For operation closer to that of Excel, see the version available in the repository FilterDataGrid-Beta.
This version uses a new filtering method that is completely different from the current version or the one commonly used to filter data (as far as I know).
-
There are two ways to install :
-
NuGet command : Install-Package FilterDataGrid
-
Or manually add FilterDataGrid.dll as reference in your project
-
Add Namespace into your xaml :
<Window xmlns:control="https://filterdatagrid.control.com/2021" ..
- Control
<control:FilterDataGrid
FilterLanguage="English" DateFormatString="d" ShowStatusBar="True" ShowElapsedTime="False"
ExcludeFields="lastname,age,manager" ...
-
Properties
- ShowStatusBar : displays the status bar, default : false
- ShowElapsedTime : displays the elapsed time of filtering in status bar, default : false
- ShowRowsCount : display the number of rows, default : false
- FilterLanguage : translation into available language, default : English
- ExcludeFields : comma separated fields to exclude from filter, only works in AutoGenerateColumns mode
- DateFormatString : date display format, default : "d"
⚠️ Before version 1.2.5.2, you must set the "Time" part of the DateTime fields to zero, otherwise the filter doesn't work.
see the documentation "Standard date and time format strings" -
Custom TextColumn / CheckBoxColumn
If you add custom columns, you must set AutoGenerateColumns="False"
<control:FilterDataGrid.Columns> <control:DataGridTextColumn IsColumnFiltered="True" ... /> <control:DataGridCheckBoxColumn IsColumnFiltered="True" ... />
-
Custom TemplateColumn
⚠️ FieldName property of DataGridTemplateColumn is required<control:FilterDataGrid.Columns> <control:DataGridTemplateColumn IsColumnFiltered="True" FieldName="LastName" ... />
You can define a global style which overrides the default style of "FilterDataGrid"
<Style
x:Key="FilterDatagridStyle"
BasedOn="{StaticResource {ComponentResourceKey TypeInTargetAssembly=control:FilterDataGrid,
ResourceId=FilterDataGridStyle}}"
TargetType="{x:Type control:FilterDataGrid}">
<Setter Property="Margin" Value="10" />
<Setter Property="RowHeaderWidth" Value="40" />
...
</Style>
Intel Core i7, 2.93 GHz, 16 GB, Windows 10, 64 bits.
Tested on the "Last name" column of the demo application using a random distinct name generator, between 5 and 8 letters in length.
The elapsed time decreases based on the number of columns and filtered items.
Number of rows | Opening of the PopUp | Applying the filter | Total (PopUp + Filter) |
---|---|---|---|
10 000 | < 1 second | < 1 second | < 1 second |
100 000 | < 1 second | < 1 second | < 1 second |
500 000 | ± 1.5 second | ± 1 second | ± 2.5 seconds |
1 000 000 | ± 3 seconds | ± 1.5 seconds | ± 4.5 seconds |