[英]Responsive DataTables being drawn twice
表定義......
<table id="planRouteTable" class="table table-striped table-hover table-bordered responsive">
<thead>
<tr>
<th>Type</th>
....other columns....
</tr>
</thead>
</table>
JS定義
基本選項
baseDataTableOptions: {
processing: true,
serverSide: true,
responsive: true,
pageLength: 25
},
在里面
let options = $.extend({}, window.bp.baseDataTableOptions, {
ajax: {
url: window.bp.apiPath + 'data-tables/users-assigned-inspections'
},
columns: [
{ data: 'policy_type', name: 'policy_type', className: 'text-center', orderable: false },
/* Other columns */
{
target: -1,
data: null,
className: "text-right",
orderable: false,
defaultContent: `
<button class="[ btn btn-primary ]">Add to Route</button>
`
}
]
});
$('#planRouteTable').DataTable(options);
我遇到的問題是,只要table
元素添加了responsive
類,以便啟用DataTables的響應版本,它就會繪制兩次。 通常情況下,我不在乎,但由於這是服務器端,它會兩次點擊API端點並隨機從服務器觸發401
響應。
服務器端呈現由Laravel DataTables插件處理。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.