Export selected rows only to excel
Export selected rows only to excel
aliB
Posts: 6Questions: 0Answers: 0
Hi,
I created two button, one to download the entire list in excel and one to download only the visible list
"aButtons": [
{
"sExtends": "xls",
"sFileName": "projectsList.xls",
"sButtonText": "Download All To Excel"
},
{
"sExtends": "xls",
"sFileName": "visibleProjectList.xls",
"sButtonText": "Download Visible List To Excel",
"bSelectedOnly": true,
"fnClick": function ( nButton, oConfig, oFlash ) {
this.fnSelect( $('tbody tr') );
this.fnSetText(oFlash, this.fnGetTableData(oConfig));
}
}
]
},
The download all to excel is working fine, but when i click download visible list it the generated excel rows are not the same one that are selected. By default they are sorted by IDs, when I download the full list, it is fine and sorted by IDs but when I download visible list the excel sheets contains 50 rows sorted by name(iDisplayLength is 50)
Thanks
I created two button, one to download the entire list in excel and one to download only the visible list
"aButtons": [
{
"sExtends": "xls",
"sFileName": "projectsList.xls",
"sButtonText": "Download All To Excel"
},
{
"sExtends": "xls",
"sFileName": "visibleProjectList.xls",
"sButtonText": "Download Visible List To Excel",
"bSelectedOnly": true,
"fnClick": function ( nButton, oConfig, oFlash ) {
this.fnSelect( $('tbody tr') );
this.fnSetText(oFlash, this.fnGetTableData(oConfig));
}
}
]
},
The download all to excel is working fine, but when i click download visible list it the generated excel rows are not the same one that are selected. By default they are sorted by IDs, when I download the full list, it is fine and sorted by IDs but when I download visible list the excel sheets contains 50 rows sorted by name(iDisplayLength is 50)
Thanks
This discussion has been closed.
Replies
Allan
This is the full initialization
oTable = jQuery("#projects-table").dataTable({
"oLanguage": {
"sEmptyTable": "No Data Found"
},
"bPaginate": true,
"bLengthChange": true,
"iDisplayLength": 50,
"bInfo": true,
"sPaginationType": "full_numbers",
"bFilter": true,
"sDom": 'T<"clear">frtlip',
"oTableTools": {
"sSwfPath": "/media/swf/copy_csv_xls_pdf.swf",
"sRowSelect": "multi",
"aButtons": [
{
"sExtends": "xls",
"sFileName": "projectsList.xls",
"sButtonText": "Download All To Excel"
},
{
"sExtends": "xls",
"sFileName": "visibleProjectList.xls",
"sButtonText": "Download Visible List To Excel",
"bSelectedOnly": true,
"fnClick": function ( nButton, oConfig, oFlash ) {
this.fnSelect( $('tbody tr') );
this.fnSetText(oFlash, this.fnGetTableData(oConfig));
}
}
]
},
"bSort": true,
});
Allan
please only modify the sSwfPath in JS to make the download work
thanks
Thanks