Seems like it should be easy but...
Does anyone know how to return the current rows from a filtered dataTable? The oTable.fnGetNodes()
method returns
Thanks AlecBoutin, that's the easiest way.
I am trying to search into multiple tables arranged in tabs, and I want to display the table where a result is found.
Quite easy with your solution
// make the global search input search into all tables (thanks to a class selector)
$('#oversearch').on( 'keyup', function () {
$('.table').DataTable().search( this.value ).draw();
var row = $('.table').DataTable().$('tr', { "filter": "applied" });
console.log(row.parents("div")[1]);
});
you can then navigate into whatever parent you need with the parents() jquery. (here I'm choosing the 2nd div parent encountered)
You can get the visible rows list changing the fnGetHiddenTrNodes function as follows.
$.fn.dataTableExt.oApi.fnGetVisibleTrNodes = function (oSettings, arg1, arg2) {
/* Note the use of a DataTables 'private' function thought the 'oApi' object */
var anNodes = this.oApi._fnGetTrNodes(oSettings);
var anDisplay = $('tbody tr', oSettings.nTable);
var visibleNodes = [];
for (var i = 0; i < anDisplay.length; i++) {
var iIndex = jQuery.inArray(anDisplay[i], anNodes);
if (iIndex != -1) {
visibleNodes.push(anDisplay[i]);
}
}
/* Fire back the array to the caller */
return visibleNodes;
}