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

136
Views
jQuery - DataTables - Cómo hacer clic en datos de fila - .Net 6 MVC

He seguido varios ejemplos pero aún no he encontrado una solución. Tengo una aplicación web MVC, las tablas de datos se cargan dentro de una vista parcial (que luego llama a instantiateDataTable ). Estoy agregando mi código JS para obtener los datos de la fila en la que se hizo clic en la vista que llamó a esta vista parcial.

He intentado algo como esto, pero ambos console.logs vuelven como indefinidos.

 $('#resultsGrid tbody').on('click', function() { var row = $(this).parents('tr')[0]; //for row data //console.log(table.row(row).data().id); var data = $('resultsGrid').DataTable().row(this).data(); console.log(row); console.log(data); });

Ver violín JS

https://jsfiddle.net/p2one80j/1/

¿Algún consejo sobre por qué mi código no funciona? AIT

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Utilice este código en su lugar:

 $(document).ready(function() { var myTable = $('#resultsGrid').DataTable( { } ); $('#resultsGrid tbody tr').on('click', function() { var data = myTable.row(this).data(); console.log(data); }); } );

Producción:

["102", "Un nombre", "222 The Street", "Una ciudad", "IL", "90210", ""]

["100", "Un nombre", "123 La calle", "Una ciudad", "IL", "90210", ""]

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