我正在使用 Kendo ui 网格:http://demos.telerik.com/kendo-ui/grid/index
我现在正在进行服务器端排序,我想要的是当“没有可用记录”时,我想禁用某些列上的排序。
那么该怎么做呢?
注意:我正在使用 kendo ui 脚本。
最佳答案
我们无法在 kendo Grid 中设置运行时启用/禁用排序,但我们可以通过使用下面的代码片段间接实现此操作。
<body>
<div id="grid"></div>
<script src="http://demos.telerik.com/kendo-ui/content/shared/js/products.js"></script>
<script>
$(document).ready(function () {
//To test your requirement please remove comment from below code line
//products = null;
$("#grid").kendoGrid({
dataSource: {
data: products,
schema: {
model: {
fields: {
ProductName: { type: "string" },
UnitPrice: { type: "number" },
UnitsInStock: { type: "number" },
Discontinued: { type: "boolean" }
}
}
}
},
height: 550,
groupable: true,
sortable: true,
columns: [
"ProductName",
{ field: "UnitPrice", title: "Unit Price", format: "{0:c}", width: "130px" },
{ field: "UnitsInStock", title: "Units In Stock", width: "130px" },
{ field: "Discontinued", width: "130px" }
]
});
$("#grid .k-grid-header .k-link").click(function (e) {
if ($("#grid").data("kendoGrid").dataSource.data().length == 0) {
e.stopPropagation();
}
});
});
</script>
</body>
如果有任何疑问,请告诉我。
关于kendo-ui - 当 kendo ui 网格中没有可用记录时,如何禁用列排序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33412268/