I am using datatable 1.10 and select tag filtering for gender column. I have come across a problem where selecting male also displays results of female as male is a subset of female. I have tried the following methods to make it work such that the table filters the exact expression.
https://datatables.net/reference/api/search()
I have tried comment from this particular page which tells us to try the following code
regExSearch = '^\\s' + myValue +'\\s*$';
table.column(columnNo).search(regExSearch, true, false).draw();
In my code:
var regex = 'Male|Female|Other'
var regExSearch = '^\\s' + regex +'\\s*$';
var select = $('<select><option value=""></option></select>')
.appendTo($(this).empty())
.on('change', function () {
table.column(i)
.search(regExSearch, true, false)
.draw();
});
I have tried another method where regex is provided directly to the search method
var select = $('<select><option value=""></option></select>')
.appendTo($(this).empty())
.on('change', function () {
table.column(i)
.search("^"+"(Male|Female|Other)"+"$", true, false)
.draw();
});
I have tried these to to avail. Any input on this would be welcome