regex filter doesnot work
regex filter doesnot work
james7
Posts: 3Questions: 1Answers: 0
I want some columns can be filtered by exact match, such as "5" will match 5, instead of 5, 15, 151 etc. After reading lots of examples here, I did it like this:
table.columns().eq( 0 ).each( function ( colIdx ) {
$('input', table.column(colIdx ).footer()).on( 'keyup change', function () {
var val =$(this).val();
if(colIdx == 2)
{
var val = $.fn.dataTable.util.escapeRegex(val);
var val = val ? '^'+val+'$' : '';
table````
.column(colIdx)
.search(val, true, false)
.draw();
}
else{
table
.column(colIdx)
.search(val)
.draw();
}
} );
However, the search cannot match anything. Does some one have a solution? Thanks a lot in advance.
This discussion has been closed.
Answers
Nobody knows?
I've put together this test case and it appears to working now.
http://live.datatables.net/mipodoqa/1/edit
Thanks
Tom
Hi, Tom, it only works here. But if I retrieved data by the pipeline, it will not work.
Sounds like you are using server-side processing in which case you would have to do the regex filtering on the server-side.
Thanks
Tom