TableTools export PDF/Excel - cached applied filter on second export

TableTools export PDF/Excel - cached applied filter on second export

kdowlingkdowling Posts: 3Questions: 1Answers: 0

10.10.4

Hi

I can save xls/pdf files for a none-filtered table, as well as a filtered subset of the same table. (I make use of filter: "applied")

But.. only if it is the first time I save after the page is loaded. Any further save/export attempts used the 'cached' version of the first export data for that specific table. This cached version can be filter or not - depending on if the table was filtered before the first export was done.

Any advice please?

aButtons: [
    $.extend({
        sExtends: "xls",
        sTitle: pdfTitle,
        sFileName: exportFileName + '.csv'
    }, { oSelectorOpts: { filter: "applied" } }),   
    $.extend({
        sExtends: "pdf",
        sPdfOrientation: "landscape",
        sTitle: pdfTitle,
        sFileName: exportFileName + '.pdf'
    }, { oSelectorOpts: { filter: "applied" } })
]

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Hi,

    Thanks for your question. I've just put together a little test page that uses your button definitions, but unfortunately I haven't been able to reproduce the issue.

    Steps taken:

    1. Load page
    2. With the table in the unfiltered state, click the PDF export to download the PDF
    3. Confirm there are 57 rows in the created PDF file
    4. Back in the browser filter using "12".
    5. Export a new PDF, overwriting the old one
    6. Check that the new PDF has only 23 rows.

    Could you confirm if I have performed the correct steps?

    Many thanks,
    Allan

  • kdowlingkdowling Posts: 3Questions: 1Answers: 0

    Thanks, only see the response now.

    I tested again and found that my fancy nested buttons are the cause. I can live without that so not urgent.

    Thanks very much for the help!

    Difference indicated below:

    // This work: every PDF contains the correct applied filter (or unfiltered)
    aButtons: [
        $.extend({
            sExtends: "xls",
            sTitle: pdfTitle,
            sFileName: exportFileName + '.csv'
        }, { oSelectorOpts: { filter: "applied" } }),
        $.extend({
            sExtends: "pdf",
            sPdfOrientation: "landscape",
            sTitle: pdfTitle,
            sFileName: exportFileName + '.pdf'
        }, { oSelectorOpts: { filter: "applied" } })
    ]
    
    // This don't work: every PDF print, but always contains the content of the very first PDF printed
    //aButtons: [{
    //    sExtends: "collection",
    //    sButtonText: "Export",
    //    aButtons: [
    
    //            $.extend({
    //                sExtends: "xls",
    //                sTitle: pdfTitle,
    //                sFileName: exportFileName + '.csv'
    //            }, { oSelectorOpts: { filter: "applied" } }),
    
    //            $.extend({
    //                sExtends: "pdf",
    //                sPdfOrientation: "landscape",
    //                sTitle: pdfTitle,
    //                sFileName: exportFileName + '.pdf'
    //                //sPdfSize: "A3"
    //            }, { oSelectorOpts: { filter: "applied" } })
    
    //    ]
    //}]
    
  • kdowlingkdowling Posts: 3Questions: 1Answers: 0

    Just a note - I upgraded versions as well:
    DataTables 1.10.7
    TableTools 2.2.4
    Editor 1.4.2

    <link href="/Content/DataTables-1.10.7/media/css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
    <script src="/Content/DataTables-1.10.7/media/js/jquery.dataTables.js"></script>
    
    <link href="/Content/DataTables-1.10.7/extensions/TableTools/css/dataTables.tableTools.css" rel="stylesheet" type="text/css" />
    <script src="/Content/DataTables-1.10.7/extensions/TableTools/js/dataTables.tableTools.js"></script>
    
This discussion has been closed.