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

112
Vistas
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
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