regex filter doesnot work

regex filter doesnot work

james7james7 Posts: 3Questions: 1Answers: 0
edited July 2016 in Free community support

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.

Answers

This discussion has been closed.