Export only filtered records in jquery-datatables
I am using jquery-datatables in my application which displays over 1000 records. I am using the jQuery table-tools extension to display buttons to save format CVS
. If the user enters a keyword into the global filter and hits it CSV
, I want to export only the filtered rows. How would I do this using JQuery-datatables? I tried the following code but with no success. Please let me know where I am going wrong.
var table=$('#dataTable-state').dataTable({
"jQueryUI": true,
"dom": 'T<"clear">lfrtip',
"sPaginationType": "full_numbers",
"aaData": $scope.data,
"bFilter": true,
"oSearch": {"bRegex":true, "bSmart": false},
"aoColumns": [
{ "mData": "name" },
{ "mData": "age" },
{ "mData": "city" },
{ "mData": "state" }
]
});
var tableTools = new $.fn.dataTable.TableTools( table);
$( tableTools.fnContainer() ).insertAfter('div#dataTable-state_wrapper');
source to share
Try adjusting Table Tools options, for example here: http://datatables.net/forums/discussion/21730/exporting-only-filtered-data-using-tabletools-button-collections
In particular, part of the "oSelectorOpts": { filter: 'applied'}
code
source to share