Question

I know that datatables allow you hide columns and filter rows.

Tabletools allow users to be able to download the table data as CSV.

However, it seems that it downloads everything.

Is there a way to only download what is shown? What I mean by this is after filtering entries and/or hiding columns, is it possible to download that data result only?

Was it helpful?

Solution

Yes, look at ajax buttons mColumns option :

This parameters defines which columns should be used as the data source for the export. The parameter can either be a string with a value of 'all', 'visible' or 'hidden' - or an array of integers with the column indexes to be exported.

This default value is all. In the options, define the CSV download button like this :

...
oTableTools: {
    sSwfPath: "path-to-your/copy_csv_xls_pdf.swf",
    aButtons: [
        { sExtends : "csv",
          mColumns : "visible"
        }
    ]
}
...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top