You are so close in your edit, what you have tried, except that you lack the must important thing : Defining the "scope" or sType of your filter plugin. The function is never called, right? This is because the plugin is not associated with a sType
.
To get your code to work simply declare the plugin like this :
$.fn.dataTableExt.ofnSearch['string'] = function ( data ) {
return ! data ?
'' :
typeof data === 'string' ?
..
..
}
See this fiddle -> http://jsfiddle.net/Y5ycM/ I have turned some "Internet Explorer" columns into "Internet éxplorer", some "Opera" to "?pera" etc, Try search for ex
or op
.
See https://datatables.net/development/filtering, section "Type based column filtering
" :
When you assign the sType for a column (or have it automatically
detected for you by DataTables or a type detection plug-in), you will
typically be using this for custom sorting, but it can also be used to
provide custom filtering options. This is done by adding functions to
the the object with a parameter name which matches the sType for that
target column:
I guess there here is a typo or oversight in the documentation, it says
$.fn.dataTableExt.ofnSearch
but should correctly be $.fn.dataTableExt.ofnSearch[sType]
, as the example just after clearly points out.
Update. Allan Jardine confirms this is a bug in 1.9.4 here :
Yup - bug in 1.9.4. 1.9.4 broke this part of the code unfortunately.
It also effects the removal of HTML tags from the filter, since that
was using the same mechanism. It is fixed in the 1.10 betas though.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…