这个问题在这里已经有了答案:
有没有办法禁用jQuery数据表的初始排序? 4个答案 当使用jQuery DataTables 4个答案 时,禁用第一列的自动排序 如何禁用Angular Datatables中的初始数据排序? 1个答案请帮我禁用Metronic Admin Theme的排序顺序。 或者只是禁用sortorder,直到用户点击sortorder图标。
我遵循这一点 ,但不知何故,它不与我一起工作。
我已经将columnDefs中的代码(从assets / pages / scripts / table-datatables-managed.min.js )更改为:
columnDefs: [{ orderable: false, targets: [0] },但它不起作用。 刷新页面时,图标排序始终激活。 但是当我从这个文件中更改语言时,它正在运行。 我已经在/assets/global/scripts/datatable.js中执行过相同的操作,但这不起作用。
请帮忙。
This question already has an answer here:
Is there a way to disable initial sorting for jquery DataTables? 4 answers Disable automatic sorting on the first column when using jQuery DataTables 4 answers How to disable initial Ordering of data in Angular Datatables? 2 answersPlease help me to disable the sortorder of Metronic Admin Theme. Or just maybe disable sortorder until user click on the sortorder icon.
I follow this, but somehow, it's not working with me too.
I already change the code from columnDefs (from assets/pages/scripts/table-datatables-managed.min.js) into:
columnDefs: [{ orderable: false, targets: [0] },But it's not working. The icon sort always activate when I refresh page. But when I change language from this file, it's working. I already do the same in /assets/global/scripts/datatable.js but it's not work too.
Please help.
最满意答案
这是一个有效的例子: 但是当我从这个文件中更改语言时,它正在运行。
提供一个链接到你不工作的代码
编辑:要完全禁用排序,请在初始设置中使用此选项
"ordering": false,虽然要禁用特定列,请在初始设置中使用此列
"columns": [ { "orderable": true }, { "orderable": true }, { "orderable": false }, { "orderable": false }, { "orderable": false }, { "orderable": true } ]这个例子可以帮助你更好地理解排序
https://jsfiddle.net/g1y8eu8v/1/
以下是一些参考链接:
https://datatables.net/reference/option/columns.orderable
https://datatables.net/reference/option/ordering
https://datatables.net/reference/option/columns.orderSequence
So a working example: But when I change language from this file, it's working.
Provide a link to your not working code
Edit: To disable sorting completely, use this in your init setting
"ordering": false,While to disable for specific column(s), use this in your init setting
"columns": [ { "orderable": true }, { "orderable": true }, { "orderable": false }, { "orderable": false }, { "orderable": false }, { "orderable": true } ]This example might help you understand sorting better
https://jsfiddle.net/g1y8eu8v/1/
Here are some reference links:
https://datatables.net/reference/option/columns.orderable
https://datatables.net/reference/option/ordering
https://datatables.net/reference/option/columns.orderSequence
更多推荐
发布评论