Output Widget: export table caption with output_includeCaption (like output_includeFooter)
Closed this issue · 2 comments
tomaszn commented
Hi!
It would be great if an option like output_includeCaption existed for Output Widget. When exporting to CSV one could use it to prepend a title to the table data, so the CSV file would be ready to print after opening in Excel.
Mottie commented
Hi @tomaszn!
From looking at the CSV specification (RFC 4180), I don't see any standard defined for adding a caption or title to CSV data.
I just pushed an update to the output widget which allows you to use the output_callback
function to return a modified string instead of just a boolean. Use it like this (demo):
output_callback : function(config, data) {
return config.$table.children('caption').text() + '\n' + data;
}
With this change you can do whatever you want to the data.
tomaszn commented
Thanks a lot! And usually we need to trim spaces from the text: ...text().trim() +...