我在rails应用程序中使用jquery数据表。我想将默认订单添加到特定列。我有以下jquery代码,
$(document).ready(function(){
$('#sample-table-2').DataTable({
responsive: true,
"pagingType": "simple",
bJqueryUI: true,
bServerSide: true,
"aaSorting": [[ 4, "asc" ]], //
sAjaxSource: $('#sample-table-2').data('source'),
"columnDefs": [
{ "width": "10%", "targets": column_count }
]
})
.on( 'order.dt', function () { eventFired( 'Order' ); } )
.on('page', function () {setTimeout(function(){hideCellsOnMobile();},1000)} )
.on( 'search.dt', function () {setTimeout(function(){hideCellsOnMobile();},1000)});
$("table#sample-table-2").parent().addClass("no-padding")
});
但是这个默认排序没有得到应用。
答案 0 :(得分:0)
您使用的是哪个版本?你能试试吗?
$(document).ready(function(){
$('#sample-table-2').DataTable({
responsive: true,
"pagingType": "simple",
bJqueryUI: true,
bServerSide: true,
order: [[ 4, "asc" ]], //
sAjaxSource: $('#sample-table-2').data('source'),
"columnDefs": [
{ "width": "10%", "targets": column_count }
]
})
.on( 'order.dt', function () { eventFired( 'Order' ); } )
.on('page', function () {setTimeout(function(){hideCellsOnMobile();},1000)} )
.on( 'search.dt', function () {setTimeout(function(){hideCellsOnMobile();},1000)});
$("table#sample-table-2").parent().addClass("no-padding")
});