I'm trying to implement a MudTable with grouping with the MudBlazor component library. As per the documentation, you must define the group definition like so:
@code {
private TableGroupDefinition<Element> _groupDefinition = new()
{
GroupName = "Group",
Indentation = false,
Expandable = true,
IsInitiallyExpanded = false,
Selector = (e) => e.Group
};
}
Which is used in the component like so:
<MudTable Items="@Elements"
...
GroupBy="@_groupDefinition">
However I get the following errors:
On _groupDefinition
:
CS0718: CategoryTypes.Element: static types cannot be used as type arguments
On (e)
CS0721: CategoryTypes.Element: static types cannot be used as parameters
I understand that static classes cannot be instantiated and therefore the errors make sense, but how did the developers get this to compile?
I am using .net 6, Blazor Webassembly, and MudBlazor v6.0.10.
As commented by Jesse Good, I got caught out by the example having a class of Element
which also existed in the MudBlazor Library as a static class! I replaced that class with my own, i.e.:
private TableGroupDefinition<Subcategory> _groupDefinition = new()
{
GroupName = "Category",
Indentation = false,
Expandable = true,
IsInitiallyExpanded = false,
Selector = (c) => c.CategoryId
};