DataGrid.Reset isn't resetting default sort icons

If you set default SortOrder to Descending on columns, calling DataGrid.Reset clears the sort but doesn't clear the descending icon. If you change the sort to ascending, Reset returns the icon to descending.

sample DataGridMultipleSortPage.razor

@page "/datagrid-multi-sort"

@using RadzenBlazorDemos.Data
@using RadzenBlazorDemos.Models.Northwind
@using Microsoft.EntityFrameworkCore

@inject NorthwindContext dbContext

<h1>DataGrid <strong>Multiple Column Sorting</strong></h1>


<RadzenExample Name="DataGrid" Source="DataGridMultipleSort" Heading="false">
    <RadzenButton Text="Reset" Click="@(async () => {@dataGrid.Reset(); await dataGrid.Reload(); StateHasChanged(); })"/> 
    <RadzenDataGrid @ref=dataGrid PageSize="5" AllowMultiColumnSorting="true" AllowPaging="true" AllowSorting="true" Data="@employees" TItem="Employee" ColumnWidth="400px">
        <Columns>
            <RadzenDataGridColumn TItem="Employee" Property="FirstName" Title="First Name" Width="150px" SortOrder=SortOrder.Descending/>
            <RadzenDataGridColumn TItem="Employee" Property="LastName" Title="Last Name" Width="150px" SortOrder=SortOrder.Descending/>
            <RadzenDataGridColumn TItem="Employee" Property="BirthDate" Title="Birth Date" FormatString="{0:d}" Width="150px" />
            <RadzenDataGridColumn TItem="Employee" Property="Country" Title="Country" Width="150px" />
            <RadzenDataGridColumn TItem="Employee" Property="Notes" Title="Notes" />
        </Columns>
    </RadzenDataGrid>
</RadzenExample>
@code {
    RadzenDataGrid<Employee> dataGrid;

    IEnumerable<Employee> employees;

    protected override void OnInitialized()
    {
        employees = dbContext.Employees;
    }
}

Hi @JohnRobinson,

You will need to use variables instead

here is an example:

<RadzenExample Name="DataGrid" Source="DataGridMultipleSort" Heading="false">
    <RadzenButton Text="Reset" Click="@(async () => { firstNameSortOrder = null; lastNameSortOrder = null; dataGrid.Reset(); })"/> 
    <RadzenDataGrid @ref=dataGrid PageSize="5" AllowMultiColumnSorting="true" AllowPaging="true" AllowSorting="true" Data="@employees" TItem="Employee" ColumnWidth="400px">
        <Columns>
            <RadzenDataGridColumn TItem="Employee" Property="FirstName" Title="First Name" Width="150px" SortOrder=@firstNameSortOrder />
            <RadzenDataGridColumn TItem="Employee" Property="LastName" Title="Last Name" Width="150px" SortOrder=@lastNameSortOrder />
            <RadzenDataGridColumn TItem="Employee" Property="BirthDate" Title="Birth Date" FormatString="{0:d}" Width="150px" />
            <RadzenDataGridColumn TItem="Employee" Property="Country" Title="Country" Width="150px" />
            <RadzenDataGridColumn TItem="Employee" Property="Notes" Title="Notes" />
        </Columns>
    </RadzenDataGrid>
</RadzenExample>
@code {
    RadzenDataGrid<Employee> dataGrid;

    IEnumerable<Employee> employees;

    SortOrder? firstNameSortOrder = SortOrder.Descending;
    SortOrder? lastNameSortOrder = SortOrder.Descending;

    protected override void OnInitialized()
    {
        employees = dbContext.Employees;
    }
}
1 Like