php – JQuery DataTables – Customize Header

Question:

I did a lot of research and couldn't figure out how to customize the pdf report header that I generate from the plugin; For example, the "sTitle": "Groups" is the title that is in the header, but it leaves with the plugin's default styling, and I also don't know how to add a subtitle with its own style, center, add a date, etc.

Here's the table call:

$("#dinamicTable").dataTable({
    "sDom": 'T<"clear">lfrtip',
    "oTableTools": {
        "sSwfPath": "webroot/libs/datatables/js/media/swf/copy_csv_xls_pdf.swf",
        "aButtons": [ 
            {
                "sExtends": "pdf",
                "sTitle": "Grupos"
            },
            {
                "sExtends": "xls",
                "sTitle": "Grupos"
            }
        ]
    }
});

And the Table:

<table id="dinamicTable" class="table table-bordered table-striped table-condensed">
    <thead>
        <tr>
            <th width="10%">ID</th>
            <th>GRUPO</th>
            <th width="10%">STATUS</th>
            <th width="10%">OPÇÕES</th>
        </tr>
    </thead>
    <tbody>
        <?php foreach ($view_grupos as $grupo) : ?>
            <tr>
                <td><?php echo $grupo['grup_id']; ?></td>
                <td><?php echo $grupo['grup_nome']; ?></td>
                <td align="center"><?php echo $grupo['grup_status']; ?></td>

            </tr>
        <?php endforeach; ?>
    </tbody>
    <tfoot>
        <tr>
            <th>ID</th>
            <th>GRUPO</th>
            <th>STATUS</th>
            <th>OPÇÕES</th>
        </tr>
    </tfoot>
</table>

Answer:

Man, I've hit my head a lot with this problem. I read a question on the forum and, according to the creator of the feature Allan Jardine, there is no way to style the "sTitle". It does not accept slashes, hyphens or certain special characters. The author said he is developing new solutions and looking for a better API.

Scroll to Top