I am trying to get the row number from datatable and pass in to some update function.Some time it giving row number as [Object object] Here is my code:
var table = $('#example').DataTable();
$('#example tbody').on( 'click', 'tr', function ()
{
var idx = table.row( this ).index();
alert(idx);//Some times it alerts [Object object]
}
You could use
$('#example tbody').on( 'click', 'td', function ()
{
var tr = $(this).closest("tr");
var rowindex = tr.index();
alert(rowindex);
});
this way you'll have the index value of the row.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With