Regex was not a handy solution for me as it require lot of exceptions in the code.
So, my solution was to add in the jquery.datatable.min.js a new option 'exactvalue' with default value false (to avoid compatibility problems)
[...]
p.columns.push({data:n,name:u.sName,searchable:u.bSearchable,exactvalue:u.bExactvalue,orderable:u.bSortable,
[...]
d.bFilter&&(m("sSearch_"+l,sa.sSearch),m("bRegex_"+l,sa.bRegex),m("bSearchable_"+l,u.bSearchable),m("bExactvalue_"+l,u.bExactvalue));
[...]
q.models.oColumn={idx:null,aDataSort:null,asSorting:null,bSearchable:null,bExactvalue:null,bSortable:null,bVisible:null
[...]
q.defaults.column={aDataSort:null,iDataSort:-1,asSorting:["asc","desc"],bSearchable:!0,bExactvalue:false,bSortable:!0,
[...]
This new option will be sent along the other data in the post:
[...]
columns[5][searchable]: true
columns[5][exactvalue]: true
columns[5][orderable]: true
[...]
After that, change the php ssp class to accept the new value. Modify filter function in the ssp changing:
if ( $requestColumn['searchable'] == 'true' ) {
if ( $requestColumn['exactvalue'] == 'true' ) {
$binding = self::bind( $bindings, $str, PDO::PARAM_STR );
$columnSearch[] = ($isJoin) ? $column['db']." = ".$binding : "`".$column['db']."` = ".$binding;
}else{
$binding = self::bind( $bindings, '%'.$str.'%', PDO::PARAM_STR );
$globalSearch[] = ($isJoin) ? $column['db']." LIKE ".$binding : "`".$column['db']."` LIKE ".$binding;
}
}
and repeat on the individual column filtering
if ( $requestColumn['searchable'] == 'true' && $str != '' ) {
if ( $requestColumn['exactvalue'] == 'true' ) {
$binding = self::bind( $bindings, $str, PDO::PARAM_STR );
$columnSearch[] = ($isJoin) ? $column['db']." = ".$binding : "`".$column['db']."` = ".$binding;
}else{
$binding = self::bind( $bindings, '%'.$str.'%', PDO::PARAM_STR );
$columnSearch[] = ($isJoin) ? $column['db']." LIKE ".$binding : "`".$column['db']."` LIKE ".$binding;
}
}
Now, in your table columnDefs definition, simply add
{'targets': 5, 'exactvalue': true}
and your column will be filtered with exact value.