I'm using the Telerik Blazor Grid with dynamic data (`Dictionary<string, object>`). Paging, sorting, and filtering work, but grouping doesn't.
It seems Telerik grouping relies on CLR properties (e.g., `Employee.Department`), while my data is stored as dictionary key/value pairs. I also tried using a `DataTable`, but grouping still doesn't work.
Has anyone successfully implemented grouping with `Dictionary<string, object>` or `DataTable`? Is there a supported solution for dynamic data?
# Minimal Code
@page "/1"
@using Telerik.Blazor.Components
@using Telerik.DataSource;
@using Telerik.DataSource.Extensions;
<TelerikGrid TItem="Dictionary<string, object>"
Pageable="true"
Groupable="true"
Sortable="true" OnRead="OnLoadData"
Navigable="true"
PageSize="10"
SortMode="Telerik.Blazor.SortMode.Single"
FilterMode="@Telerik.Blazor.GridFilterMode.FilterRow"
Height="500px">
<GridColumns>
@foreach(var col in Columns)
{
<GridColumn Field="@col.Key" Title="@col.Key" FieldType="typeof(string)" />
}
</GridColumns>
</AgirhDataGrid>
@code {
public List<KeyValuePair<string, string>> Columns { get; set; }
private Task OnLoadData(GridReadEventArgs args)
{
var request = new DataSourceRequest
{
Groups = args.Request.Groups,
};
// GetData it's a System.DataTable
var dataSource = GetData.ToDataSourceResult(request);
args.Data = dataSource.AggregateResults ?? dataSource.Data;
args.Total = dataSource.Total;
return Task.CompletedTask;
}
}
