How to update a specific cell data on click of row

How to update a specific cell data on click of row

LeftPinkieLeftPinkie Posts: 6Questions: 4Answers: 0

How do I update a cell data on click event of a table row?

var myTable = $( '#table' ).DataTable({}) ;
$( '#table tbody' ).on( 'click' , 'tr' , function() {} ) ;

This question has an accepted answers - jump to answer

Answers

  • bindridbindrid Posts: 730Questions: 0Answers: 119
    Answer ✓

    "this" in your event handler will be the row dom object so you use that to get the data object.

    var myTable = $( '#table' ).DataTable({}) ;
    $( '#table tbody' ).on( 'click' , 'tr' , function() {
          var rowdata = $("#table").DataTable().row(this).data();
        } ) ;
    

    That will give you the data for the row. How you update that value depends on what your data structure looks like (array of arrays or array of objects).

  • LeftPinkieLeftPinkie Posts: 6Questions: 4Answers: 0

    Thank you... that is exactly what I was looking for.

This discussion has been closed.