Getting record count into the MESSAGE when Printing/PDF

Getting record count into the MESSAGE when Printing/PDF

seyad96seyad96 Posts: 4Questions: 1Answers: 0

I use Datatable extensively and have been able to do some 'crazy' hacking to get the most out of it. My latest roadblock is I am trying to display the total records in the Datatable (from an Ajax call) into the MESSAGE. Due to order of execution, I don't see how I can get the record count and display it besides making an AJAX call prior to initialization just to get total record count. Is there a way? Is there a way to get the record count and display it AFTER the table is display in both the PRINT and PDF?

Answers

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin
    edited January 2016

    Can you just call the page.info() method to get the information required?

    Allan

    edit

    AFTER the table is display in both the PRINT and PDF?

    I missed that bit. In the PDF you would use the customize callback to modify the document. Likewise in the Print button you would do the same, although obviously it will be a bit different in each for how it should actually be done.

  • seyad96seyad96 Posts: 4Questions: 1Answers: 0

    I tried just about everything. The problem is that the MESSAGE seems to be processed prior to the DataTable being available and not sure how I would alter the document in the PRINT or in the PDF between the DataTable loaded and before the process is completed.

    I even tried saving the record count in a hidden text box (using InitComplete) and then accessing the element but the element is not available to the PRINT/PDF routines. The solution was to put the record count in the first FOOTER Cell (which brings me to another question regarding why we can't use ColSpan in the FOOTER?)

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin

    which brings me to another question regarding why we can't use ColSpan in the FOOTER?

    In part because there is no way to represent a colspan in CSV and since the export for all types share code, they need to use the lowest common denominator.

    Did you try using the customize method for the buttons? Can you link to a test case of what you used? That should allow you to get the data from the API and modify the generated document.

    Allan

  • seyad96seyad96 Posts: 4Questions: 1Answers: 0

    How do I get access to the MESSAGE element in order to modify it's content in the CUSTOMIZE method?

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin

    This is in the PDF? You'd need to inspect the array that is passed into the customize method and change it as you require. A simple console.log() of the array would show you its structure, or you could read the source for for the HTML5 PDF button which would also show you.

    Allan

This discussion has been closed.