我正在尝试实现一个MudTable,并使用MudBlazor组件库进行分组。根据文档,您必须定义组定义如下:
@code {
private TableGroupDefinition<Element> _groupDefinition = new()
{
GroupName = "Group",
Indentation = false,
Expandable = true,
IsInitiallyExpanded = false,
Selector = (e) => e.Group
};
}在组件中使用,如下所示:
<MudTable Items="@Elements"
...
GroupBy="@_groupDefinition">但是,我得到以下错误:
论_groupDefinition:CS0718: CategoryTypes.Element: static types cannot be used as type arguments
论(e) CS0721: CategoryTypes.Element: static types cannot be used as parameters
我理解静态类不能被实例化,因此错误是有意义的,但是开发人员是如何编译的呢?
我使用的是.net 6、Blazor组件和MudBlazor v6.0.10。
发布于 2022-06-06 18:55:44
正如杰西·古德( Jesse )评论的那样,我被一个Element类的例子吓到了,这个类也作为静态类存在于MudBlazor库中!我用自己的课程代替了那门课,即:
private TableGroupDefinition<Subcategory> _groupDefinition = new()
{
GroupName = "Category",
Indentation = false,
Expandable = true,
IsInitiallyExpanded = false,
Selector = (c) => c.CategoryId
};https://stackoverflow.com/questions/72510779
复制相似问题