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

126
Vistas
Jquery data tables need to show only selected rows from an integer array of IDs

I have a drop down with checkboxes in it. When I select multiple items, I have a method which gets those IDs in an integer array. In my data table one of the column, lets say 'User_ID:name' has those IDs. I want to loop through the data table and show only rows of selected IDs in the integer array. If array is empty, no rows should be visible.

I wrote a method, but it's only showing me only 1 row and it keeps overwriting that row when looping through.

var Gridupdate = function () {
    int[] checked = Checkbox.getCheckedIds(); /// integer array of selectedIDs from a checkbox
    if (dtable) {
        for (i = 0; i < checked.length; i++) {
            dtable.column("User_ID:name").search(checked[i].toString()).draw();
        }
    }
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can use regex in "DataTables" to achieve this. Add this to your "DataTables' initialisation options".

"search": {
    "regex": true, // enables the table to be filtered using regular expresion
    "smart": false // disables the table's "smart search" ability. Ensures a more accurate search.
}

Example:

$('#example').DataTable( {
    "search": {
        "regex": true,
        "smart": false
    }
});

And change your method to this

var Gridupdate = function () {
    var checked = Checkbox.getCheckedIds(); /// integer array of selectedIDs from a checkbox
    if (dtable) {
        dtable.column("User_ID:name").search(checked.join('|')).draw(); // eg .search(1|2|4)
    }
};
about 4 years ago · Juan Pablo Isaza Denunciar
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