Skip to content
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

DataGrid: SortDefinitions paramter is ignored #9021

Open
1 of 2 tasks
Wasserwecken opened this issue May 20, 2024 · 0 comments
Open
1 of 2 tasks

DataGrid: SortDefinitions paramter is ignored #9021

Wasserwecken opened this issue May 20, 2024 · 0 comments

Comments

@Wasserwecken
Copy link

Wasserwecken commented May 20, 2024

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 is SortMode.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

  1. Set SortDefinitions
  2. Set SortMode to Single

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

  • I agree to follow this project's Code of Conduct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant