JS dataTables.fixedHeader different width between header and datas
Asked Answered
R

1

7

I use the javascript plugin dataTables.fixedHeader and fill the data with ajax. Now I have the problem, that the width of each data-column is dynamically and the header stays on the same static width.

Different width

Code:

HTML:

<table class="table table-striped table-bordered table-hover" id="custTable">
                    <thead>
                        <tr>
                            <th>
                                ......
                            </th>
                            <th>
                                ......
                            </th>
                            <th>
                                ......
                            </th>
......
                        </tr>
                    </thead>
                    <tbody id="dataList"></tbody>
                </table>

JS:

table = $('#custTable').DataTable({
            "dom": "frtiS",
            "deferRender": true,
        });

Fill it:

$('#custTable').dataTable().fnAddData([
               xyz, xyz, xyz, ...
                        ]);
Rostand answered 2/7, 2015 at 12:34 Comment(1)
Can you provide more codeAsleep
F
3

Disable automatic column widths.

JS

table = $('#custTable').DataTable({
            "dom": "frtiS",
            "deferRender": true,
            "autoWidth": false
        });

http://datatables.net/reference/option/autoWidth

Featherstitch answered 11/7, 2015 at 10:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.