Using DataTables 1.10.5 - Cannot filter exported data

Using DataTables 1.10.5 - Cannot filter exported data

mtrayn01mtrayn01 Posts: 12Questions: 3Answers: 0
edited February 2015 in Free community support

I am new to DataTables, and am using the DataTables script within an XML Stylesheet. I only mention this part since I have to be more careful with syntax to be sure tags are correctly ended. I also am not able to use the dom options that include tags such as below as this gives syntax errors when I publish my website.

"dom": '<"toolbar">C<"clear">lfrtip<"clear">T',

I have everything working except that when I click on a button to export (clipboard, CSV or PDF), all rows within the table are exported and not just the filtered rows.

I have tried several different attempts at using oSelectorOpts but cannot get it to take effect.

This is my script:

 var table = $('#mytable').DataTable( {
        dom: 'TCRlfrtip',
        stateSave: true,
        tableTools: {
                    "sSwfPath": "DataTables-1.10.5/extensions/TableTools/swf/copy_csv_xls_pdf.swf",
                    "oTableTools": {
                        "oSelectorOpts": { "filter": "applied" },
                        "aButtons": [
                            {
                                "sExtends": "copy",
                                "sButtonText": "Copy to clipboard",
                            }
                        ]
                    }
        },
        colVis: {
            exclude: [],
            groups: [
                {
                    title: "Group1",
                    columns: [ 0, 1, 2, 3, 4, 5]
                },
                {
                    title: "Group2",
                    columns: [ 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ]
                }
            ]
        }
    } );

Please can somebody help?

Thanks,

Mark T

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,681Questions: 1Answers: 10,498 Site admin

    Is this a new issue in 1.10.5? The title of the post appears to suggest it might be?

    It looks like the issue is that your oSelectorOpts hasn't actually been applied to the button. You need to put it in the button definition.

    Allan

  • mtrayn01mtrayn01 Posts: 12Questions: 3Answers: 0

    Hi Allan, I have tried your suggestion but still see the full number of rows copied to clipboard instead of the filtered number.

    tableTools: {
                        "sSwfPath": "../DataTables-1.10.5/extensions/TableTools/swf/copy_csv_xls_pdf.swf",
                        "oTableTools": {
                            "aButtons": [
                                {
                                    "sExtends": "copy",
                                    "sButtonText": "Copy to clipboard",
                                    "oSelectorOpts": { "filter": "applied" },
                                }
                            ]
                        }
            },
    
  • allanallan Posts: 63,681Questions: 1Answers: 10,498 Site admin

    Can you link to the page so I can debug it then please.

    Allan

  • mtrayn01mtrayn01 Posts: 12Questions: 3Answers: 0

    I sent you a PM with the web page and user credentials.

    Thanks Allan.

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

    Thanks for the link. IN your DataTables configuration you have:

            tableTools: {
                "sSwfPath": "../DataTables-1.10.5/extensions/TableTools/swf/copy_csv_xls_pdf.swf",
                "oTableTools": {
                    "aButtons": [{
                        "sExtends": "copy",
                        "sButtonText": "Copy to clipboard",
                        "oSelectorOpts": {
                            "filter": "applied"
                        },
                    }]
                }
            },
    

    It should be:

            tableTools: {
                "sSwfPath": "../DataTables-1.10.5/extensions/TableTools/swf/copy_csv_xls_pdf.swf",
                "aButtons": [{
                    "sExtends": "copy",
                    "sButtonText": "Copy to clipboard",
                    "oSelectorOpts": {
                        "filter": "applied"
                    },
                }]
            },
    

    i.e. don't have oTableTools as a property of tableTools. That isn't a property that TableTools looks for.

    Allan

  • mtrayn01mtrayn01 Posts: 12Questions: 3Answers: 0

    Perfect - that worked. Thank you Allan

This discussion has been closed.