Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make title row of generated CSV file have correct number of columns #904

Merged
merged 2 commits into from
Jun 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions static/js/vendor/DataTables/datatables.js
Original file line number Diff line number Diff line change
Expand Up @@ -27693,13 +27693,19 @@ DataTable.ext.buttons.csvHtml5 = {
var output_ = _exportData( dt, config ).str;
var data = dt.buttons.exportData( config.exportOptions );
if (data.header[2][0] == 2) {
var str = $('tr:first').text() + '\n'
var output = str + output_
}
else{
var str = $('h1:last').text() + '\n'
var output = str + output_
var caption = $('tr:first').text();
}
else {
var caption = $('h1:last').text();
}
// Generate a string of sequential commas
// As many commas as in the CSV output of the first row of the table
var commas = output_.split('\n')[0].match(/,/g) || [];
// Generate empty columns like (,"") to go after caption column
var columns = commas.reduce((function(acc) { return acc + ',""' }), '');
// Place caption row before the table output
var output = '"' + caption + '"' + columns + '\n' + output_;

var url = window.location.href;
var myRegexp = /(\d+)/g;
var regExp = /\(([^)]+)\)/;
Expand Down