Copy, CSV, XLS, PDF, Print only selected rows

Copy, CSV, XLS, PDF, Print only selected rows

majortommajortom Posts: 29Questions: 0Answers: 0
edited June 2013 in TableTools
Some of the databases that I'm working with reach into the thousands. It wouldn't really be logical to (for example) print all 3000 rows. Is there any way to print, download, copy only selected rows? I have sRowSelect set to "multi" already, and the selecting works. I am also using bSelectOnly, and it is set to true (I've tried putting the bSelectOnly just after the sRowSelect, as well as just after the first aButtons).

Here is my .js code

[code]
$(function() {
$( "#tabs" ).tabs();
});

$(document).ready(function() {
$("#tabs").tabs( {
"show": function(event, ui) {
var jqTable = $('table.display', ui.panel);
if ( jqTable.length > 0 ) {
var oTableTools = TableTools.fnGetInstance( jqTable[0] );
if ( oTableTools != null && oTableTools.fnResizeRequired() )
{
/* A resize of TableTools' buttons and DataTables' columns is only required on the
* first visible draw of the table
*/
jqTable.dataTable().fnAdjustColumnSizing();
oTableTools.fnResizeButtons();
}
}
}
} );

$('#table1').dataTable( {
"bProcessing": true,
"sPaginationType": "full_numbers",
"sAjaxSource": "scripts/script.php",
"sAjaxDataProp": "",
"aoColumns": [
{ "mData": "STREET", "sClass": "center" },
{ "mData": "HOUSE #", "sClass": "center" },
{ "mData": "YEAR", "sClass": "center" },
{ "mData": "DIA# (in#)", "sClass": "center" },
{ "mData": "PIPE MATERIAL", "sClass": "center" },
],

"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"sSwfPath": "media/swf/copy_csv_xls_pdf.swf",
"sRowSelect": "multi",
"aButtons": [ "select_all", "select_none",
{
"sExtends": "collection",
"sButtonText": "More",
"aButtons": ["copy", "csv", "xls", "pdf", "print"],
"bSelectOnly": true
}
]
}
} );
});
[/code]

Thanks for the help in advance

Replies

  • majortommajortom Posts: 29Questions: 0Answers: 0
    This is the fix:

    [code]
    $('#table1').dataTable( {
    "bProcessing": true,
    "sPaginationType": "full_numbers",
    "sAjaxSource": "scripts/script.php",
    "sAjaxDataProp": "",
    "aoColumns": [
    { "mData": "STREET", "sClass": "center" },
    { "mData": "HOUSE #", "sClass": "center" },
    { "mData": "YEAR", "sClass": "center" },
    { "mData": "DIA# (in#)", "sClass": "center" },
    { "mData": "PIPE MATERIAL", "sClass": "center" },
    ],

    "sDom": 'T<"clear">lfrtip',
    "oTableTools": {
    "sSwfPath": "media/swf/copy_csv_xls_pdf.swf",
    "sRowSelect": "multi",
    "aButtons": [ "select_all", "select_none",
    {
    "sExtends": "collection",
    "sButtonText": "More",
    "aButtons": [
    {"sExtends": "copy", "bSelectedOnly": true},
    {"sExtends": "csv", "bSelectedOnly": true},
    {"sExtends": "xls", "bSelectedOnly": true},
    {"sExtends": "pdf", "bSelectedOnly": true},
    "print"
    ]
    }
    ]
    }
    } );
    [/code]
This discussion has been closed.