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

249
Views
Pre-Filter jQuery DataTables AJAX result based on specific column value

I have a JSON file containing all the data, so basically it's the data for 10 different tables in one file. Now, when I'm on a certain page (A) I only wish to output the data from the file where the value of column[0] (my identifier sits in the first column) is "A".

I'm really not sure what to put where:

$('#example').DataTable( {
    "ajax": '../ajax/data/arrays.txt'
} );

Any ideas? Thanks!

Got it working.

$('#example').dataTable( {
    "ajax": {
        "url": "../ajax/data/arrays.txt",
        "dataSrc": function(json) {
            let data = json.data;
            let filter = data.filter(function(value, index, arr){
                return value[0] === 'A';
            });
            return filter;
        }
    }
} );
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can use the dataSrc option of the ajax configuration:

 $('#example').DataTable( { "ajax": { url: '../ajax/data/arrays.txt', dataSrc: function(json) { // run logic on json to select only your desired rows return result; } });
over 4 years ago · Santiago Trujillo Report
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!