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

111
Views
Jquery datatables custom search function on JSON data

This datatable search function looks within a data field gates which is represented in JSON as

{ "completed": [], "na": [], "open": []}

The filter function is trying to look within a the "completed" key of the gates object for an for an entry matching "TestGate", which indicates whether the testing state was completed or not. We use this result for the search filter (checkbox toggle):

$.fn.dataTable.ext.search.push(
        function (settings, data, dataIndex) {
            if ($("#checkboxRRComplete").is(":checked")) {
                let gates = data[5] || {}
                console.log(gates) \\"[obj Object]" need gate to be a JS object
                return gates.completed.includes("TestGate")
            }
            return true
        }
    )

The problem here is that function above the data input is casted to a string. So in the function scope it is "[obj Object]" and the object fields are no longer accessible. Is there a way to create custom search criteria that is JSON object friendly?

NOTE: Since running into this issue I decided to just add another field to my ajax request response to be used for filtering. However, I am still wondering if there is a better way to do this by searching objects.

about 4 years ago · Juan Pablo Isaza
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!