fnils
April 9, 2020, 12:37pm
1
I have a grid that I fill using an IQueryable.
I also have a dropdown to change how many row are shown at the time. It however only removes the bar with the step to the next/previous page there are the same amount of rows showing.
Is there a trick to getting all the rows to show when changing the pagesize?
I have made a ref="testGrid" and tried testGrid.reload() after calling the database but it doesn't change anything.
enchev
April 9, 2020, 12:55pm
2
Reload() method worked for me on our demo:
https://blazor.radzen.com/datagrid
@page "/datagrid"
@using NorthwindBlazor.Data
@using NorthwindBlazor.Models.Northwind
@using Microsoft.EntityFrameworkCore
@inject NorthwindContext dbContext
<RadzenExample Name="DataGrid">
<RadzenDropDown @bind-Value="pageSize" Data="@(new List<int>() { 1, 2, 3 })" Style="margin-bottom: 20px" Change="@Change" />
<RadzenGrid @ref="grid" AllowFiltering="true" AllowPaging="true" PageSize="@pageSize"
AllowSorting="true" Data="@employees" TItem="Employee" ColumnWidth="200px">
<Columns>
<RadzenGridColumn TItem="Employee" Property="EmployeeID" Title="Employee ID" />
<RadzenGridColumn TItem="Employee" Property="Photo" Title="Photo" Sortable="false" Filterable="false">
<Template Context="data">
<RadzenImage Path="@data?.Photo" />
</Template>
</RadzenGridColumn>
<RadzenGridColumn TItem="Employee" Property="LastName" Title="Last Name" />
<RadzenGridColumn TItem="Employee" Property="FirstName" Title="First Name" />
<RadzenGridColumn TItem="Employee" Property="Title" Title="Title" />
<RadzenGridColumn TItem="Employee" Property="TitleOfCourtesy" Title="Title Of Courtesy" />
<RadzenGridColumn TItem="Employee" Property="BirthDate" Title="Birth Date">
<Template Context="data">
@String.Format("{0:d}", data.BirthDate)
</Template>
</RadzenGridColumn>
<RadzenGridColumn TItem="Employee" Property="HireDate" Title="Hire Date">
<Template Context="data">
@String.Format("{0:d}", data.HireDate)
</Template>
</RadzenGridColumn>
<RadzenGridColumn TItem="Employee" Property="Address" Title="Address" />
<RadzenGridColumn TItem="Employee" Property="City" Title="City" />
<RadzenGridColumn TItem="Employee" Property="Region" Title="Region" />
<RadzenGridColumn TItem="Employee" Property="PostalCode" Title="Postal Code" />
<RadzenGridColumn TItem="Employee" Property="Country" Title="Country" />
<RadzenGridColumn TItem="Employee" Property="HomePhone" Title="Home Phone" />
<RadzenGridColumn TItem="Employee" Property="Extension" Title="Extension" />
<RadzenGridColumn TItem="Employee" Property="Notes" Title="Notes" />
</Columns>
</RadzenGrid>
</RadzenExample>
@code {
int pageSize = 1;
IEnumerable<Employee> employees;
RadzenGrid<Employee> grid;
protected override void OnInitialized()
{
employees = dbContext.Employees.ToList();
}
void Change(object value)
{
grid.Reload();
}
}
fnils
April 9, 2020, 1:09pm
3
If you change .ToList to .Select(x => x); Does that still work?