简体   繁体   English

如何删除或隐藏过滤器运算符下拉列表

[英]How to Remove or Hide Filter Operators Dropdown List

The filterMenuInit event isn't firing on my grid. filterMenuInit事件未在我的网格上触发。 I want the AccountNumber field to have a filter, however I want to completely remove or hide the dropdown where it says "Is Equal To", "Does Not Contain", etc. The code to remove the dropdown is in the filterMenuInit configuration but the function isn't firing when the grid loads. 我希望AccountNumber字段具有过滤器,但是我想完全删除或隐藏下拉菜单,其中显示“等于”,“不包含”等信息。要删除下拉菜单的代码位于filterMenuInit配置中,但是网格加载时未触发功能。 Here is my code: 这是我的代码:

<div id="grid"></div>
    <script>
        $(document).ready(function() {
            $("#grid").kendoGrid({
                dataSource: {
                    transport: {
                        read: "/api/client"
                    },
                    schema: {
                        model: {
                            fields: {
                                ClientID: { type: "number" },
                                Name: { type: "string" },
                                Branch: { type: "string" },
                                Department: { type: "string" },
                                AccountNumber: { type: "number" }
                            }
                        }
                    },
                    pageSize: 20,
                    serverPaging: false,
                    serverFiltering: false,
                    serverSorting: true
                },
                height: 500,
                scrollable: true,
                filterable: {
                    mode: "row",
                    extra: "false"
                },
                filterMenuInit: function(e) {
                    if (e.field === "AccountNumber") {
                    var firstValueDropDown = e.container.find("select:eq(0)").data("kendoDropDownList");

                        setTimeout(function () {
                            firstValueDropDown.wrapper.hide();
                        })
                    }
                },
                sortable: false,
                pageable: true,
                columns: [{
                    field: "AccountNumber",
                    width: "150px",
                    title: "Account #"
                }, {
                    field: "Branch",
                    filterable: false,
                    width: "100px",
                    title: "Branch"
                }, {
                    field: "Department",
                    filterable: false,
                    width: "100px",
                    title: "Department"
                }, {
                    field: "Name",
                    template: '<a href="/client/#=ClientID#">#=Name#</a>',
                    title: "Client Name"
                }, {
                    filterable: "false",
                    template: '<span class="glyphicon glyphicon-file"></span><a href="/client/#=ClientID#/invoice">View Invoices</a>',
                    width: "150px"
                }, {
                    filterable: "false",
                    template: '<span class="glyphicon glyphicon-list-alt"></span> <a href="/client/#=ClientID#/workorder">View Work Orders</a>',
                    width: "150px"
                }
            ]
            });
        });
    </script>

Entered debug mode in the browser and the event never fires so the dropdown remains active. 在浏览器中进入调试模式,事件从不触发,因此下拉列表保持活动状态。

you can use following code at you column definition 您可以在列定义中使用以下代码

filterable: {
    cell: {
        showOperators: false
    }
}

or you can define in schema that it is number, it will solve it as well 或者您可以在模式中定义它是数字,它也会解决它

Here is demo 这是演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM