问题
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?
回答1:
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"
}
]
}
...
来源:https://stackoverflow.com/questions/23620818/datatables-is-it-possible-to-download-only-the-data-that-is-shown-as-csv