Skip to content

Commit

Permalink
DataGrid Reset() should reset to original columns order
Browse files Browse the repository at this point in the history
  • Loading branch information
enchev committed Nov 1, 2024
1 parent bf5265c commit 7de5d90
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions Radzen.Blazor/RadzenDataGrid.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2043,6 +2043,7 @@ public void Reset(bool resetColumnState = true, bool resetRowState = false)
});
selectedColumns = allColumns.Where(c => c.Pickable && c.GetVisible()).ToList();
sorts.Clear();
columns = allColumns.Where(c => c.Parent == null).ToList();
}
}

Expand Down
7 changes: 4 additions & 3 deletions RadzenBlazorDemos/Pages/DataGridColumnReoder.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

@inherits DbContextPage

<RadzenButton Text="Change page state" Click="@((args) => { StateHasChanged(); })" class="rz-my-4" />
<RadzenDataGrid AllowColumnReorder="true" ColumnReordering="@OnColumnReordering" ColumnReordered="@OnColumnReordered" TItem="Employee"
<RadzenButton Text="Reset" Click="@((args) => { grid.Reset(); })" class="rz-my-4" />

<RadzenDataGrid @ref=grid AllowColumnReorder="true" ColumnReordering="@OnColumnReordering" ColumnReordered="@OnColumnReordered" TItem="Employee"
AllowFiltering="true" FilterPopupRenderMode="PopupRenderMode.OnDemand" AllowColumnResize="true" FilterMode="FilterMode.Advanced" PageSize="5" AllowPaging="true" AllowSorting="true" Data="@employees" ColumnWidth="160px" LogicalFilterOperator="LogicalFilterOperator.Or">
<Columns>
<RadzenDataGridColumn Property="@nameof(Employee.EmployeeID)" Filterable="false" Title="ID" Frozen="true" Width="80px" TextAlign="TextAlign.Center" Reorderable="false" Resizable="false" />
Expand Down Expand Up @@ -34,7 +35,7 @@

@code {
EventConsole console;

RadzenDataGrid<Employee> grid;
IEnumerable<Employee> employees;

protected override async Task OnInitializedAsync()
Expand Down

0 comments on commit 7de5d90

Please sign in to comment.