我正在使用 MudDataGrid 组件:https://dev.mudblazor.com/components/datagrid#default-data-grid
我试图在页面加载后立即添加过滤器,但我找不到执行此操作的文档。
我还没有找到任何使用 MudDataGrid 组件进行类似操作的示例。
您可以在 MudBlazor 文档中看到(高级过滤)
并用
OnInitializedAsync
方法更改数据
protected override async Task OnInitializedAsync()
{
Elements = await httpClient.GetFromJsonAsync<List<Element>>("webapi/periodictable");
_selectedItems = Elements.ToHashSet();
_filterItems = Elements.ToHashSet();
_filterDefinition = new FilterDefinition<Element>
{
FilterFunction = x => _filterItems.Contains(x)
};
}
负责过滤的线路
FilterFunction = x => _filterItems.Contains(x)