Skip to content

Instantly share code, notes, and snippets.

@UndefinedOffset
Last active September 23, 2016 20:55
Show Gist options
  • Save UndefinedOffset/9bb08f8551c14ee3648b to your computer and use it in GitHub Desktop.
Save UndefinedOffset/9bb08f8551c14ee3648b to your computer and use it in GitHub Desktop.
//Ref: https://www.datatables.net/release-datatables/extensions/TableTools/examples/select_multi.html
var tableRows=[];
var tableHeadings=[];
$('#example thead th').each(function() {
tableHeadings.push($(this).text());
});
tableRows.push(tableHeadings.join(','));
$('#example tbody tr.selected').each(function() {
var row=[];
$(this).find('td:not(.hidden)').each(function() {
row.push($(this).text());
});
if(row.length>0) {
tableRows.push(row.join(','));
}
});
var csv=tableRows.join("\r\n");
var newWin=window.open();
$(newWin.document.body).text(csv);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment