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

140
Visualizações
jQuery DataTable retain the search filter, in a generic class

I integrated on my application, datatables, to give more functionalities to my HTML tables. It works correctly, however, when I want to perform a search, through an input, I would like to save the state of the table, at the page change, but also the associated filter, in the input. To do this, here is the code that works (provided that it is put in each HTML file containing a table):

stateSaveParams: function( settings, data ) {
    data.**col1_filter** = $('#**col1_filter**').val()
 },
stateLoadParams: function( settings, data ) {
   $('#**col1_filter**').val(data.**col1_filter**)
},

What I want to do now, is to generalize this code, within a "script.js" file, so that the next time I create a table, I just have to apply the "datatable" class, and everything is done directly.

My question is : how can I specify the name of the input field, for "stateSaveParams" and "stateLoadParams", instead of mentioning in hardcopy the name of the field (which is not named the same each time) ?

Thank you very much in advance, I want to specify, that I did not find a solution, despite my multiple searches, before this post.

about 4 years ago · Santiago Gelvez
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