fiduswriter / simple-datatables

DataTables but in TypeScript transpiled to Vanilla JS
Other
1.31k stars 231 forks source link

Respect existing table footer and caption #347

Closed SandroHc closed 6 months ago

SandroHc commented 6 months ago

Preserves <tfoot> and <caption> tags from the original HTML table in the rendered datatable.

See the following example for a practical use case.

<table id="example-table">
    <caption>List of smartphones.</caption> <!-- custom caption -->
    <thead>
        <tr>
            <th>Model</th>
            <th>Price</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>iPhone 14</td>
            <td>$699</td>
        </tr>
        <tr>
            <td>iPhone 15</td>
            <td>$799</td>
        </tr>
    </tbody>
    <tfoot style="font-weight: bold"> <!-- custom footer -->
        <tr>
            <td>Total</td>
            <td>$1498</td>
        </tr>
    </tfoot>
</table>

<script>
    const dt = new DataTable("example-table", {
        // This also works:
        // caption: "List of smartphones."
    });
</script>