PdfHtml5 – count rows on eatch page

PdfHtml5 – count rows on eatch page

smichaelxxsmichaelxx Posts: 4Questions: 1Answers: 0

Hi,
I have a question is it possibile to add information about how many rows in tables on each pages exist when exporting to pdf for example. in footer?

Answers

  • rf1234rf1234 Posts: 2,809Questions: 85Answers: 406

    use "messageBottom" as described here: https://datatables.net/reference/button/pdf

    Don't know how to count the records per page when exporting. @allan: can you help with this please

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin

    messageButton can be given as a function so you could do something like:

    messageBottom: function () {
      return 'Rows shown: '+myTable.rows().count();
    }
    

    Allan

  • rf1234rf1234 Posts: 2,809Questions: 85Answers: 406

    Thanks @allan! This doesn't count the records per page but the records of the entire document. Which is fine for me but not @smichaelxx 's question I guess.

    @smichaelxx: Don't you have the same amount of records on every page except for maybe the first (if you use a "title") and the last one? I wouldn't know why I needed this on every page ... but anyway ...

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin

    If you are looking for the number of records shown on each page in the PDF, I think you'd need to dive into the pdfmake documentation. I'm not even sure that information is available from their APIs.

    Allan

  • smichaelxxsmichaelxx Posts: 4Questions: 1Answers: 0

    Thanks very much @rf1234 & @allan.

    Information about number of records on the page would help me in calculating the column summaries on each page.
    I tried with footerCallback (https://datatables.net/examples/advanced_init/footer_callback.html) but while I was exporting all data I got the sum of all records but not for records on current page.

    I thought about using the “customization” option where

    doc ["footer"] = function (currentPage, pageCount),

    but I got only page number and total numbers of pages.

    Is there maybe some way to detect ”breake-page” option or group rows on each page?

    @allan, you are right that in pdfmake documentation, it is not available to get information about count rows on page.

    Thanks in advance for your help

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin

    The issue here is that DataTables and Buttons don't "know" anything about the page structure. It just says to pdfmake - here is a list of rows. It is pdfmake that then splits it into multiple pages. So I'm afraid this is a pdfmake question that I don't have the knowledge to address.

    Allan

This discussion has been closed.