Export to PDF the results with search criterai

Export to PDF the results with search criterai

TheBigFrenchTheBigFrench Posts: 2Questions: 1Answers: 0

Hi,
I am trying to export to PDF the results of a filtered database. Everything is working well exept that I can't find a way to export to the PDF, above the table, the list of all the columns with a filtered criteria (name of the column: entered value by the user).
I am using the script in this exemple : https://datatables.net/extensions/fixedheader/examples/options/columnFiltering.html
In this exemple, if in the column NAME I enter "AI" and in the column POSITION I enter "ER", it will be filtered with three results, no problem to export it, but I need also to add in the PDF :
NAME = AI
POSITION = ER
Thanks a lot for your help
Regards

Answers

  • allanallan Posts: 63,531Questions: 1Answers: 10,474 Site admin

    Use the messageTop option of pdfHtml5. It can be given as a function so you can query the document to find out what filters are applied and modify your message as needed.

    Allan

  • TheBigFrenchTheBigFrench Posts: 2Questions: 1Answers: 0

    Hi Allan,
    Thanks for your feedback.
    For people who may be interested, here is the piece of code I use :

    $('#example').DataTable().columns().every(function () {
        if (this.search() != '') {
            i++;
            rslt += this.header().innerText + " = " + "*" + this.search().replace('((((', '').replace('))))', '') + "* - ";
        }
    });
    (i == 1) ? s = '' : s = 's';
    
    

    The s variable is only to be able to add an s if plural.

    Then when configuring pdfmake, I create a header, in the header I added a table, where I simply put the rslt text.

    It is very simple, but hard to find ;-)

    Now I am looking for a way to export in PDF NO RECORD without any table when the filters show no results !!!!! Still not found ;-)

Sign In or Register to comment.