Datatables - Is it possible to download only the data that is shown as CSV?

梦想与她 提交于 2019-12-25 01:46:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!