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

552
Views
Datatables no muestra mis datos pero después de aplicar el filtro

Estoy completando una tabla a través de Ajax JSON con tablas de datos, este es mi código JS:

 $(document).ready(function () { $.ajax({ url: "../WebService.asmx/LoadUsers", type: 'POST', datatype: 'json', //content: 'json', lo mismo que arriba contentType: 'application/json; charset=utf-8', success: function (data) { var datos = JSON.parse(data.d); // METODO JQUERY DATATABLES Documentación $('#tblUsers').DataTable({ data: datos, columns: [ { 'data': 'id' }, { 'data': 'username' }, { 'data': 'password' }, { 'data': 'dregistered' }, { 'data': null, 'defaultContent': "<img src='../assets/img/delete.png' id='btnDel' style='width: 22px; cursor:pointer;' />" } // ], responsive: true }); /*DataTables instantiation.*/ /*$("#tblUsers").DataTable();*/ }, error: function () { alert('Fail!'); } }); });

tabla html:

 <table id="tblUsers" class="table table-bordered nowrap" style="width:100%"> <thead> <tr> <th>Id</th> <th>Usuario</th> <th>Contraseña</th> <th>Fecha</th> </tr> </thead> <tfoot> <tr> <th>Id</th> <th>Usuario</th> <th>Contraseña</th> <th>Fecha</th> </tr> </tfoot> </table>

Mi tabla después de cargar la página html no muestra datos, parece que no se representa al principio, pero después de aplicar el filtro de columna o cambiar las entradas, los datos muestran: Filtrado por número de entradas

Filtrado por orden de columnas

¿Me estoy perdiendo de algo? 🤔

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Su problema es probablemente que está tratando de establecer 5 columnas de datos (incluso si la quinta tiene data: null ) pero solo tiene 4 columnas en su <table> HTML.

Si observa su consola , probablemente debería haber algún error como Cannot read property 'style' of undefined o similar. Entonces, el error interrumpe la carga de los datos dentro de la tabla.

Cambie su HTML a esto (agregando un <th></th> adicional) y debería funcionar bien:

 <table id="tblUsers" class="table table-bordered nowrap" style="width:100%"> <thead> <tr> <th>Id</th> <th>Usuario</th> <th>Contraseña</th> <th>Fecha</th> <th></th> </tr> </thead> <tfoot> <tr> <th>Id</th> <th>Usuario</th> <th>Contraseña</th> <th>Fecha</th> <th></th> </tr> </tfoot> </table>
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!