Reputation: 67
I am using a very old version of DataTable Jquery lib, v 1.1.6. I am trying to get all filtered data across all pages, but it always returns the whole unfiltered data. Here is what I got:
var getAllFilteredData = function() {
var tableData = $('#myTable').dataTable({"bFilter": "applied"}).fnGetData();
...//do sth with the data;
}
I have tried the several ways I found on web but it doesn't work for me, most of them said "function not defined". I am assuming it is because my version.
$('#myTable').dataTable().$('tr', {"filter":"applied"}));
$("#myTable").dataTable()._('tr', {"filter":"applied"});
$("#myTable").dataTable().fnFilter("some text");
I tried not to upgrade my version because it would break other codes.
Does anyone know how to address this issue? Please help.. Thanks!!!!
Upvotes: 1
Views: 703
Reputation: 67
Found a solution that solve my problem. Refer to THIS LINK. Tried this:
$.fn.dataTableExt.oApi.fnGetFilteredNodes = function ( oSettings ) {
var anRows = [];
for ( var i=0, iLen=oSettings.aiDisplay.length ; i<iLen ; i++ ) {
var nRow = oSettings.aoData[ oSettings.aiDisplay[i] ].nTr;
anRows.push( nRow );
}
return anRows; };
There is a built-in fn in the newer version of DataTable. But if you are using a old version. You can try using this. It works for me.
Upvotes: 1