簡體   English   中英

響應式DataTables被繪制兩次

[英]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插件處理。

這是2.2版本的錯誤

來自開發者

它是2.2%版本的響應中的一個錯誤我害怕。 使用每晚版本將解決它直到下一個版本。 我會很快標記它,因為它會頻繁出現。

所以2個選項:

等待官方標簽,或者:

bower install https://nightly.datatables.net/responsive/js/dataTables.responsive.min.js

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM