MudDataGrid: Allow overriding default filter operators per column#10254
MudDataGrid: Allow overriding default filter operators per column#10254ScarletKuro merged 13 commits intoMudBlazor:devfrom
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #10254 +/- ##
==========================================
+ Coverage 91.54% 91.56% +0.01%
==========================================
Files 415 415
Lines 13017 13025 +8
Branches 2457 2460 +3
==========================================
+ Hits 11917 11926 +9
+ Misses 549 547 -2
- Partials 551 552 +1 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
tjscience
left a comment
There was a problem hiding this comment.
Everything looks good, aside from the small improvement in GetFilterOperators.
| } | ||
| else | ||
| { | ||
| return [.. FilterOperators]; |
There was a problem hiding this comment.
It seems unnecessary to use a collection expression here. You can just use FilterOperators.ToArray() which is much lighter.
There was a problem hiding this comment.
You can just use
FilterOperators.ToArray()which is much lighter.
I think that's pretty much the same.
Can't we just use IReadOnlyCollection? Then no ToArray is needed that will allocate since HashSet implements it
I don't think we need access by indexer here?
I would say IReadOnlyCollection > Array most of the time
There was a problem hiding this comment.
It's not the same. Although, it is a small difference. I do agree that IReadOnlyCollection here would prevent the need for a conversion to an array. The collection expression just leads to unnecessary IL is all.
There was a problem hiding this comment.
It's not the same. Although, it is a small difference.
You are right, actually I looked in sharplab and it generates
private string[] Array
{
get
{
HashSet<string> filterOperators = FilterOperators;
int num = 0;
string[] array = new string[filterOperators.Count];
HashSet<string>.Enumerator enumerator = filterOperators.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
string text = (array[num] = enumerator.Current);
num++;
}
return array;
}
finally
{
((IDisposable)enumerator).Dispose();
}
}
}
for HashSet. I really thought expression collection is more smarter and would fallback to simple .ToArray lol.
|



Description
Added a
FilterOperatorsproperty to the data gridColumn. If supplied, these operators would be used instead of the defaultTypeoperators. This allows developers to control the filter operators available to the end user.Note: New operators cannot be created, the must already exist in the list of default operators.
Resolves #8996
How Has This Been Tested?
Visually and Unit Tests
Type of Changes
Checklist
dev).