Tuples are awkward - they don't use properties but fields (RadzenDataGrid prefers properties). Also you can't get a tuple member by its name via reflection. tupleType.GetField("one")
does not work - it has to be tupleType.GetField("Item1")
.
Still you can display your tuple collection like this (with some limitations listed below the code):
<RadzenDataGrid Data="@foo">
<Columns>
<RadzenDataGridColumn TItem="(int id, double one, double two)" Title="Id">
<Template>
@context.id
</Template>
</RadzenDataGridColumn>
<RadzenDataGridColumn TItem="(int id, double one, double two)" Title="One">
<Template>
@context.one
</Template>
</RadzenDataGridColumn>
<RadzenDataGridColumn TItem="(int id, double one, double two)" Title="Two">
<Template>
@context.two
</Template>
</RadzenDataGridColumn>
</Columns>
</RadzenDataGrid>
@code {
List<(int id, double one, double two)> foo = new() { };
protected override void OnInitialized()
{
foo.Add((1, 2, 3));
}
}
Here are a few RadzenDataGrid features which rely on properties and hence won't work with tuples:
- Sorting (can be implement with custom code by handling the LoadData event)
- Filtering (can be implemented as custom code too)
- Editing (not sure if you need it)