How to get column value with click of column button?

How to get column value with click of column button?

sadequesadeque Posts: 1Questions: 1Answers: 0
edited November 2016 in Free community support

When I click a button I'm getting data[1] and data[2] value undefined. Can anyone tell me where I am getting wrong?

$(document).ready(function () { var table = $('#example').DataTable({ "ajax": "user.json", "columns": [ { "className": 'details-control', "orderable": false, "data": null, "defaultContent": '' }, {"data": "Name"}, {"data": "Phone"}, {"data": "Role"}, { "targets": -1, "data": null, "defaultContent": "Edit" } ], "order": [[1, 'asc']] }); $('#example tbody').on('click', 'button', function () { var data = table.row($(this).parents('tr')).data(); alert(data[1] + "'s Phone is: " + data[2]); }); // Add event listener for opening and closing details $('#example tbody').on('click', 'td.details-control', function () { var tr = $(this).closest('tr'); var row = table.row(tr); if (row.child.isShown()) { // This row is already open - close it row.child.hide(); tr.removeClass('shown'); } else { // Open this row row.child(format(row.data())).show(); tr.addClass('shown'); } }); });

<html>

Name Phone Role
Name Phone Role

</html>

This discussion has been closed.