【发布时间】:2023-03-18 10:06:01
【问题描述】:
我正在尝试为 DataTable 文本列提供特定的排序顺序,而不仅仅是按字母升序或降序排序。
例如,我的目标是提供“升序”顺序,例如 [Orange, Apple, Grape, Watermelon] where a column has only those values and when sort "descending" is selected, the order of the column will follow [Watermelon, Grape, Apple, Orange].
我还没有找到在 DataTables 中轻松完成此操作的方法,希望得到任何指导!
更新 枚举插件应该是我需要的——但我无法让它工作。我已经添加到我的 html 中:
<script src="//cdn.datatables.net/plug-ins/1.10.12/sorting/enum.js"></script>
我已经添加到我的代码中:
$.fn.dataTable.enum( ['Orange','Apple','Grape','Watermelon'] );
$("#example").DataTable();
我什至尝试将表中的特定列明确定义为“枚举”:
$("#example").DataTable({
"columns": [
{"type": "enum"}
]
});
我有什么遗漏或尚未尝试的吗?
【问题讨论】:
标签: jquery datatables