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

144
Views
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
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!