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

StackOverflow https://stackoverflow.com/questions/23620818

  •  21-07-2023
  •  | 
  •  

문제

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?

도움이 되었습니까?

해결책

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"
        }
    ]
}
...
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top