Jquery Datatables - Customize Header

Asked

Viewed 1,373 times

3

I searched a lot and could not figure out how to customize the header of the report in pdf that Gero from the plugin; for example, the "sTitle": "Groups" is the title that is in the header, but it comes out with the default styling of the plugin, and also don’t know how to add a subtitle with your own style, center, add a date, etc.

Follow the call from the table:

$("#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>
  • Just for the sake of conscience, you’ve tried:<th align="center" width="10%">ID</th> if that’s what I understand?!

  • 1

    No, it’s not thead no. It’s the same report header. For example, the "sTitle": "Grupos" is the title, however it comes out with the default styling of the plugin, and also do not know how to add a subtitle with your own style, etc...

  • @Leofelipe, I have a question similar to yours. Please see this link, can you help me? http://answall.com/questions/52567/exibir-elemento-search-do-jquery-datatables-em-uma-div-espec%C3%ADfica

2 answers

2


Dude, I’ve hit my head a lot with this problem. I read a question on forum and, according to the creator of the functionality Allan Jardine, there is no way to stylize the "sTitle". It does not accept either bars, hyphen or certain special characters. The author said he is developing new solutions and looking for a better API.

-1

Use:

var table = $('#dinamicTable').DataTable( {
        responsive: true,
initComplete: function () {
            $('div.fg-toolbar:first').append('<span>Titulo</span>');
        }

.......

Browser other questions tagged

You are not signed in. Login or sign up in order to post.