afnFiltering: aData behaves differently after upgrading DataTables
afnFiltering: aData behaves differently after upgrading DataTables
Hi! recently I discovered that my filtering function was not working anymore for some columns.
My current version is 1.10.4
After searching the forum, what I could understand is that the aData parameter of the afnFiltering function contains the cells' text of the row. In previous versions of DataTables it appears that aData used to contain the HTML content of the cells.
Wich actually is quite a problem because one might have many renders that display HTML, for instance :
render: function(data, type, full)
{
if(data=='0') return '<img src="pix/no.png" />';
else if(data=='1') return '<img src="pix/yes.png" />';
return '-';
}
$.fn.dataTableExt.afnFiltering.push(
function( oSettings, aData, iDataIndex ) {
console.log(aData);
}
);
In previous versions of DataTables, the console output of aData would clearly show the <img> tags,
while now I just get an empty string (obviously the <img> tag contains no text)
Then, how is it possible to filter such cells using aData, without having to query the data() of that cell in the filtering function (wich would use dramatically more CPU) ?
This question has an accepted answers - jump to answer
Answers
In 1.10 the second parameter passed into the custom filtering functions is an array of the data to be filtered. The forth parameter passed in is the raw data object for the row's data source. It might be that which you wish to use in 1.10? Documentation.
Allan
Wow... great!
Sorry for not keeping myself up to date regarding the documentation...
Thanks a lot for your quick reply and your amazing work on DataTables.