gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 05:43:20 25 4
gpt4 key购买 nike

filterMenuInit 事件未在我的网格上触发。我希望 AccountNumber 字段有一个过滤器,但是我想完全删除或隐藏显示“等于”、“不包含”等的下拉列表。删除下拉列表的代码位于 filterMenuInit 配置中,但在网格加载时该函数不会触发。这是我的代码:

<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>

在浏览器中进入 Debug模式,并且该事件永远不会触发,因此下拉列表保持事件状态。

最佳答案

您可以在列定义中使用以下代码

filterable: {
cell: {
showOperators: false
}
}

或者你可以在模式中定义它是数字,它也会解决它

这里是demo

关于javascript - 如何删除或隐藏过滤器运算符下拉列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40430556/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com