Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

192
Views
How to implement searchhighlight in column filtering with init in datatable

In my data table, I am using column filtering. I am using this functionality through the data table init method and it is working fine. code is given below

         initComplete: function() {
                    $('.dataTables_scrollBody thead tr').css({visibility:'collapse'});
                    var api = this.api();
                    api.columns().eq(0).each(function(colIdx) {
                            var cell = $('.myfilters th').eq($(api.column(colIdx).header()).index());
                            var cStyle = (cell.text() == 'Action') ? "display:none;" : "width:100%;color:black";
                            var title = "Search"
                            $(cell).html('<input type="text" style=' + cStyle + '  placeholder="' + title + '" />');
                            $('input', $('.myfilters th').eq($(api.column(colIdx).header()).index())).off('keyup change').on('keyup change', function(e) {
                                    e.stopPropagation();
                                    $(this).attr('title', $(this).val());
                                    var regexr = '({search})';
                                    alert(regexr) 
                                    var cursorPosition = this.selectionStart;
                                    api.column(colIdx).search(this.value != '' ? regexr.replace('{search}', '(((' + this.value + ')))'): '', this.value != '', this.value == '').draw();$(this).focus()[0].setSelectionRange(cursorPosition, cursorPosition);
         $('.dataTables_scrollBody thead tr').css({visibility:'collapse'});    
                            });
                    });
            },
    });

how can I use search highlight in column filtering? how can I add highlight code here in column searching?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!