admin管理员组文章数量:1395730
I have a question regarding jQuery DataTables
.I have the following situation , when table is loading everything should be sorted by third column , but at the same time , I sorting by columns should be disabled (when clicking on the header of the table), and highlighting of column on which sorting is done should be also disabled.
Please if you have any idea , share it with me. Thank You.
I have a question regarding jQuery DataTables
.I have the following situation , when table is loading everything should be sorted by third column , but at the same time , I sorting by columns should be disabled (when clicking on the header of the table), and highlighting of column on which sorting is done should be also disabled.
Please if you have any idea , share it with me. Thank You.
Share Improve this question asked Jan 25, 2016 at 19:21 Hank MooodyHank Mooody 52713 silver badges29 bronze badges 1- a quick google search turns up lots of results for this – charlietfl Commented Jan 25, 2016 at 19:29
1 Answer
Reset to default 6SOLUTION
Use order
option to define initial sorting along with columnDefs.orderable
set to false
to disable sorting for specific columns and columnDefs.targets
set to _all
to target all columns.
var table = $('#example').DataTable({
order: [[2, 'asc']],
columnDefs: [{
targets: "_all",
orderable: false
}]
});
If you don't want the sorted column to be higlighted use the following classes for your table: stripe hover row-border
, see the HTML example below:
<table id="example" class="stripe hover row-border" cellspacing="0" width="100%">
DEMO
See this jsFiddle for code and demonstration.
本文标签: javascriptjQuery DataTables how to disable sorting when clicking on table headerStack Overflow
版权声明:本文标题:javascript - jQuery DataTables how to disable sorting when clicking on table header? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744118137a2591609.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论