-
-
Notifications
You must be signed in to change notification settings - Fork 42
feat: Added filter item count to the FilterFlyout #262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a0ee89f
7badd98
dcf7ed0
a4fd038
74132ee
a8dabc9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -30,26 +30,25 @@ public virtual IList<TableViewFilterItem> GetFilterItems(TableViewColumn column, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| column.TableView.FilterDescriptions.Where( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| x => x is not ColumnFilterDescription columnFilter || columnFilter.Column != column)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var filterValues = new SortedSet<object?>(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| foreach (var item in collectionView) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var value = column.GetCellContent(item); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| filterValues.Add(IsBlank(value) ? null : value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return [.. filterValues.Select(value => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| value ??= TableViewLocalizedStrings.BlankFilterValue; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var isSelected = !column.IsFiltered || !string.IsNullOrEmpty(searchText) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (column.IsFiltered && SelectedValues[column].Contains(value)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return string.IsNullOrEmpty(searchText) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| || value?.ToString()?.Contains(searchText, StringComparison.OrdinalIgnoreCase) == true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? new TableViewFilterItem(isSelected, value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }).OfType<TableViewFilterItem>()]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return [.. collectionView.Select(column.GetCellContent) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .Select(x => IsBlank(x) ? null : x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .GroupBy(x => x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .OrderBy(x => x.Key) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .Select(x => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var value = x.Key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| value ??= TableViewLocalizedStrings.BlankFilterValue; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var isSelected = !column.IsFiltered || !string.IsNullOrEmpty(searchText) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (column.IsFiltered && SelectedValues[column].Contains(value)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return string.IsNullOrEmpty(searchText) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| || value?.ToString()?.Contains(searchText, StringComparison.OrdinalIgnoreCase) == true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? new TableViewFilterItem(isSelected, value, x.Count()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .OfType<TableViewFilterItem>() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .OrderByDescending(x => _tableView.ShowFilterItemsCount ? x.Count : 0)]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+33
to
+51
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return [.. collectionView.Select(column.GetCellContent) | |
| .Select(x => IsBlank(x) ? null : x) | |
| .GroupBy(x => x) | |
| .OrderBy(x => x.Key) | |
| .Select(x => | |
| { | |
| var value = x.Key; | |
| value ??= TableViewLocalizedStrings.BlankFilterValue; | |
| var isSelected = !column.IsFiltered || !string.IsNullOrEmpty(searchText) || | |
| (column.IsFiltered && SelectedValues[column].Contains(value)); | |
| return string.IsNullOrEmpty(searchText) | |
| || value?.ToString()?.Contains(searchText, StringComparison.OrdinalIgnoreCase) == true | |
| ? new TableViewFilterItem(isSelected, value, x.Count()) | |
| : null; | |
| }) | |
| .OfType<TableViewFilterItem>() | |
| .OrderByDescending(x => _tableView.ShowFilterItemsCount ? x.Count : 0)]; | |
| var items = collectionView.Select(column.GetCellContent) | |
| .Select(x => IsBlank(x) ? null : x) | |
| .GroupBy(x => x) | |
| .Select(x => | |
| { | |
| var value = x.Key; | |
| value ??= TableViewLocalizedStrings.BlankFilterValue; | |
| var isSelected = !column.IsFiltered || !string.IsNullOrEmpty(searchText) || | |
| (column.IsFiltered && SelectedValues[column].Contains(value)); | |
| return string.IsNullOrEmpty(searchText) | |
| || value?.ToString()?.Contains(searchText, StringComparison.OrdinalIgnoreCase) == true | |
| ? new TableViewFilterItem(isSelected, value, x.Count()) | |
| : null; | |
| }) | |
| .OfType<TableViewFilterItem>(); | |
| return [.. (_tableView.ShowFilterItemsCount | |
| ? items.OrderByDescending(x => x.Count) | |
| : items.OrderBy(x => x.Value))]; |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -260,6 +260,11 @@ public partial class TableView | |||||
| /// </summary> | ||||||
| public static readonly DependencyProperty ConditionalCellStylesProperty = DependencyProperty.Register(nameof(ConditionalCellStyles), typeof(IList<TableViewConditionalCellStyle>), typeof(TableView), new PropertyMetadata(default)); | ||||||
|
|
||||||
| /// <summary> | ||||||
| /// Identifies the <see cref="ShowFilterItemsCount"/> dependency property. | ||||||
| /// </summary> | ||||||
| public static readonly DependencyProperty ShowFilterItemsCountProperty = DependencyProperty.Register(nameof(ShowFilterItemsCount), typeof(bool), typeof(TableView), new PropertyMetadata(false)); | ||||||
|
||||||
| public static readonly DependencyProperty ShowFilterItemsCountProperty = DependencyProperty.Register(nameof(ShowFilterItemsCount), typeof(bool), typeof(TableView), new PropertyMetadata(false)); | |
| public static readonly DependencyProperty ShowFilterItemsCountProperty = DependencyProperty.Register(nameof(ShowFilterItemsCount), typeof(bool), typeof(TableView), new PropertyMetadata(false)); |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -12,7 +12,7 @@ public partial class TableViewColumnHeader | |||||
| /// <summary> | ||||||
| /// ViewModel for the options flyout in the TableViewColumnHeader. | ||||||
| /// </summary> | ||||||
| private partial class OptionsFlyoutViewModel : INotifyPropertyChanged | ||||||
| internal partial class OptionsFlyoutViewModel : INotifyPropertyChanged | ||||||
| { | ||||||
| public event PropertyChangedEventHandler? PropertyChanged; | ||||||
| private IList<TableViewFilterItem> _filterItems = []; | ||||||
|
|
@@ -114,7 +114,7 @@ public IList<TableViewFilterItem> FilterItems | |||||
|
|
||||||
| DetachPropertyChangedHandlers(); | ||||||
| _filterItems = value; | ||||||
| AttachPropertyChangedHandlers(); | ||||||
| AttachPropertyChangedHandlers(); | ||||||
|
||||||
| AttachPropertyChangedHandlers(); | |
| AttachPropertyChangedHandlers(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The expression 'A == true' can be simplified to 'A'.