我正在打印带有datatable列的表和我的订单,但是数据表更改了顺序,我可以做些什么来中止它。
我的代码
$(document).ready( function () {
$('#example').DataTable();
} );
</script>发布于 2018-11-12 01:29:48
如果你想全局禁用排序,你可以使用下面的代码:
$(document).ready(function() {
$('#dTable').dataTable(
{
"bSort" : false
}
);
});或者,如果您想要将默认排序列设置回它在后端中的状态:
$(document).ready(function() {
$('#dTable').DataTable( {
"order": [[ 3, "desc" ]]
} );
);
});发布于 2018-11-12 01:57:53
这是您的问题的有效解决方案,使用DataTables插件的bsort属性禁用默认排序
$(function(){
$("#example").dataTable({
"bSort" : false
});
})<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css">
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script>
<table id="example">
<thead>
<tr><th>Sites</th></tr>
</thead>
<tbody>
<tr><td>SitePoint</td></tr>
<tr><td>Learnable</td></tr>
<tr><td>Flippa</td></tr>
</tbody>
</table>
希望它能帮助你解决问题
发布于 2021-01-10 02:35:40
$(document).ready( function () {
$('#example').DataTable({
...,
order: [0, 'asc'],
...
});
} );或者通过放置“desc”而不是“asc”来排列降序列表。由键“order”分配的数组中的第一个值是列索引。对于可能的第一列'id‘,它是0。
你就完了。
https://stackoverflow.com/questions/53251233
复制相似问题