Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

198
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda