JSBin: http://live.datatables.net/nujehixu/3/edit?js,console,output
$(document).ready( function () {
// push our custom filter onto the stack of filters
$.fn.dataTable.ext.search.push(function(settings, searchData, index, rowData, counter) {
// get filter value
var value = $("#example_filter > label > input").val().toLowerCase();
// check filter value against original row data
var original = rowData[1].toLowerCase();
console.log(original);
return original.indexOf(value) > -1;
});
function addEllipsis(original, charLimit) {
if (original.length > charLimit) {
// substring the original and add ellipsis with a title attribute of the original
return '<div title="' + original + '">' + original.substr(0, charLimit) + '…' + '</div>';
}
// return the original value since it is already short enough
return '<div title="' + original + '">' + original + '</div>';
}
var table = $('#example').DataTable({
columnDefs: [
{
targets: 1,
render: function (data, type, row) {
// render with ellipsis if necessary
return addEllipsis(data, 6);
}
}
]
});
} );
Check out the linked example, I'm trying to use a custom filter based on the original row data, but the issue surfaces when entering a filter value like systems. The rows with Systems Administrator are filtered out when I would expect systems to match 'Systems Administrator' and show those rows.
Reading through the source, it looks like there is a global filter applied first against a search string, which is compiled from the rendered values.
Has anyone found a solution for this?