Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

146
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda