I spend all day looking for a solution on the internet, where need to export data after I have them sorted and selected rows.
I use:
dataTables 1.10.3
tabletools 2.2.3
In the code, I put the following:
$(function(){
var table = $("#price").dataTable({
//"order": [[ 3, "asc" ]],
"aoColumnDefs" : [
{
"bSortable" : false,
"aTargets" : [0, 1, 10]
}
]
});
var tableTools = new $.fn.dataTable.TableTools( table, {
"sSwfPath" : "/files/tabletools/swf/copy_csv_xls_pdf.swf",
"sRowSelect" : "multi",
"sRowSelector" : "td:first-child",
"aButtons": [
{
"sExtends": "copy",
"sButtonText": "Copy",
"mColumns": [ 3, 4, 5, 6, 7, 8, 9 ]
},
{
"sExtends": "csv",
"mColumns": [ 3, 4, 5, 6, 7, 8, 9 ]
},
{
"sExtends": "xls",
"mColumns": [ 3, 4, 5, 6, 7, 8, 9 ],
"bSelectedOnly": true,
"oSelectorOpts": {"order": "current"}
},
{
"sExtends": "pdf",
"mColumns": [ 3, 4, 5, 6, 7, 8, 9 ],
"oSelectorOpts": { "order": "current"}
},
{
"sExtends": "select_all",
"sButtonText": "Sellect all"
},
{
"sExtends": "select_none",
"sButtonText": "Desellect all"
}
]
} );
$( ".export-btn" ).append( tableTools.fnContainer());
});
I successfully export selected rows, but they are not sorted. Also I successfully export sorted data, if they are not selected rows.
Is this ever be together? Where I'm wrong?
This is my first time to use datatable and tabletools.
Thank you.