MudBlazor
MudBlazor copied to clipboard
DataGrid: SortDefinitions paramter is ignored
Bug type
Component
Component name
MudDataGrid
What happened?
Have a look at the reproduction link.
- I want to set an initial sort definition via the
SortDefinitions
-parameter. - This only works if the
SortMode
-parameter isSortMode.Multiple
. - If set to
SortMode.Single
, the initial definitions are cleared.
The bug is probably located in:
- File
MudDataGrid.razor.cs
- Method
SetParametersAsync
[Parameter] public SortMode SortMode { get; set; } = SortMode.Multiple;
// ...
public override async Task SetParametersAsync(ParameterView parameters)
{
var sortModeBefore = SortMode;
await base.SetParametersAsync(parameters);
if (parameters.TryGetValue(nameof(SortMode), out SortMode sortMode) && sortMode != sortModeBefore)
await ClearCurrentSortings();
}
Because the SortMode
is initially Multiple
, the definitions are cleared if the mode is set to Single
.
I dont know if the .Clear() makes sense at all. But it should be NOT cleared if the sort mode is set initially.
Expected behavior
Given SortDefinitions
should be work in both SortModes
Do not clear SortDefinitions
initially.
Reproduction link
https://try.mudblazor.com/snippet/QYwIEJcYRvsikHZP
Reproduction steps
On MudDataGrid
- Set
SortDefinitions
- Set
SortMode
toSingle
Relevant log output
No response
Version (bug)
6.19.1
Version (working)
No response
What browsers are you seeing the problem on?
Chrome
On which operating systems are you experiencing the issue?
Windows
Pull Request
- [ ] I would like to do a Pull Request
Code of Conduct
- [X] I agree to follow this project's Code of Conduct