help for : write search criteria text as pdf export file's messageTop text

help for : write search criteria text as pdf export file's messageTop text

infotbainfotba Posts: 17Questions: 3Answers: 0

if the search text is Tokyo then messageTo : Tokyo

Please help.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,299Questions: 26Answers: 4,945

    In the messageTop function return search() without any parameters. This should provide the global search value.

    Kevin

  • infotbainfotba Posts: 17Questions: 3Answers: 0

    dom: 'Bfrtip',
    buttons: [
    {
    extend: 'pdfHtml5',
    messageTop:function () {
    var dateNow = new Date();
    return dateNow.toLocaleString();
    },
    orientation: 'landscape',
    pageSize: 'A4',

            },
    

    ok for date but search() not

    thank you

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    I don't see the search() method being called in your messageTop function. Could you provide a link to a page showing the issue please.

    Allan

  • infotbainfotba Posts: 17Questions: 3Answers: 0

    ...
    dom: '<Bf<t>lip>',
    buttons: [
    {
    extend: 'pdfHtml5',
    messageTop:$('#dataTables_filter input').val(),
    orientation: 'landscape',
    pageSize: 'A4',

            },
    

    ....

  • kthorngrenkthorngren Posts: 21,299Questions: 26Answers: 4,945
    Answer ✓

    Have you tried this?

                    messageTop: function () {
                       return 'Search: ' + table.search();
                    },
    

    Where table is your Datatables API variable.

    Kevin

  • infotbainfotba Posts: 17Questions: 3Answers: 0

    function () {
    var table = $('#example').DataTable();
    return 'Search: ' + table.search();
    },

    excellent solve.Thank you kthorngren.

This discussion has been closed.