0
votes

Can anyone help me understand how the DataTables $.fn.dataTableExt.afnFiltering.push method works?

I know that you can subscribe some methods to do some filtering on DataTables (using a predefined signature - which accepts Settings, Data and DataIndex as inputs, and must return true or false indicating if the row should or not be shown).

My doubt is about the table in which it operates. Assuming we have more than one DataTable on a page, how can we define in which of those tables the subscribed method will be used for filtering? Will it always be used? And if this is the case, can I test (somehow) for which element is the method being executed (so i could do the filtering for the right DataTable and leave the others untouched)?

Thanks in advance.

1

1 Answers

1
votes

Ooops. Found it. Here's where i found it: How to apply filter to specific datatable

And here's what i did:

$.fn.dataTableExt.afnFiltering.push(function(oSettings, aData, iDataIndex) {
// check if current table is the table i want
if (oSettings.nTable == $('#myTableId'))
{
    return (aData[IndexOfColumnToFilter] = filterCondition)
}
// for other tables, just do not filter...
return true;
}