button to copy data 'as is' to a generated 'basic' html table for printing

button to copy data 'as is' to a generated 'basic' html table for printing

karanitskaranits Posts: 9Questions: 0Answers: 0
edited May 2012 in TableTools
Can anyone tell me how to copy the table as html 'as is' to make another simple html table. i.e i want to generate another table which would have the content of this datatable with all modification( by fnRowCallBack) intact.

What i really want is a tabletools button which would create a basic html table. which would be sent to another page and will be using a very simple print css.

There could be some a much better way to implement the following, so please help me if you can :)
right now i have made a button with does this
[code]
TableTools.DEFAULTS.aButtons=[
{
"sExtends": "text",
"sButtonText": "Custom PDF",
"mColumns": "visible",
"fnClick": function (nButton, oConfig, oFlash) {

var tableclone= $('#tableId_wrapper .dataTables_scroll').clone(true); // clone the table

headrow= $('.dataTables_scrollHead thead',tableclone); // save headers
dataset= $('.dataTables_scrollBody tbody',tableclone); // save dataset

$('*',headrow).removeAllAttr() //clean all atributes

$('tr',dataset).each(function (index, domEle){
$(this).removeClass("even").removeClass('odd').removeAttr('id'); // remove some classes and ids
});

/* =========================
now the table generated will be


headrow.html()


dataset.html()


==========================*/
}
}
];
[/code]


This works ok for datatables with a scroll, I want to make a function which is generic, in which tabletools could find on its own which table this tabletool button is clicked and generate the html so that i dont have to hardcode the table id into the function
This discussion has been closed.