MVC中的KENDOUI网格:有没有办法在某些列上隐藏过滤器?

jm.*_*jm. 7 kendo-ui

我在MVC.NET中使用KENDO UI网格.

网格配置为显示每列的列过滤器.

但是我的一些列不可过滤,所以我想隐藏过滤器.

有没有办法从C#端配置它?(不使用CSS或JS).

Ona*_*Bai 15

在你的代码中,你可能有类似的东西:

<asp:Content ContentPlaceHolderID="MainContent" runat="server">
<%: Html.Kendo().Grid(Model)
    .Name("Grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.ProductID).Groupable(false);
        columns.Bound(p => p.ProductName);
        columns.Bound(p => p.UnitPrice);
        columns.Bound(p => p.UnitsInStock);
    })
    .Groupable()
    .Pageable()
    .Sortable()
    .Scrollable()
    .Filterable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("Products_Read", "Grid"))
    )
%>
</asp:Content>
Run Code Online (Sandbox Code Playgroud)

如果您希望ProductID列不可过滤,您应该说:

<asp:Content ContentPlaceHolderID="MainContent" runat="server">
<%: Html.Kendo().Grid(Model)
    .Name("Grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.ProductID).Groupable(false).Filterable(false);
        columns.Bound(p => p.ProductName);
        columns.Bound(p => p.UnitPrice);
        columns.Bound(p => p.UnitsInStock);
    })
    .Groupable()
    .Pageable()
    .Sortable()
    .Scrollable()
    .Filterable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("Products_Read", "Grid"))
    )
%>
</asp:Content>
Run Code Online (Sandbox Code Playgroud)