如何隐藏 Blazor 中 DataGrid 中的筛选器下拉选项菜单?

问题描述 投票:0回答:1

我需要隐藏用于过滤 DataGrid 中的数据的下拉菜单,以便为 FilterText 节省一些空间。

blazor blazor-server-side blazor-bootstrap
1个回答
0
投票

您可以尝试以下示例,通过应用“按钮删除”CSS 作为第一优先级来满足您的需求。

<style>
    .myFilterRow button{
        display: none !important;
    }
</style>

<Grid TItem="Employee4" Class="table table-hover table-bordered table-striped" DataProvider="EmployeesDataProvider" AllowFiltering="true" Responsive="true"
    FiltersRowCssClass="myFilterRow" >         
    <GridColumns>    
        <GridColumn TItem="Employee4" HeaderText="Id" PropertyName="Id">          
            @context.Id
        </GridColumn>
        <GridColumn TItem="Employee4" HeaderText="Employee Name" PropertyName="Name">
            @context.Name
        </GridColumn>
    </GridColumns>
</Grid>


@code {
    private IEnumerable<Employee4> employees = default!;

    private async Task<GridDataProviderResult<Employee4>> EmployeesDataProvider(GridDataProviderRequest<Employee4> request)
    {
        if (employees is null)
            employees = GetEmployees(); 

        return await Task.FromResult(request.ApplyTo(employees));
    }

    private IEnumerable<Employee4> GetEmployees()
    {
        return new List<Employee4>
        {
            new Employee4 { Id = 107, Name = "Alice" },
            new Employee4 { Id = 110, Name = "Bob" },
        };
    }
    public class Employee4
    {
        public int Id { get; set; }
          public string Name { get; set; }
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.