How to get value of rows displayed by json datatable without selecting it?
How to get value of rows displayed by json datatable without selecting it?
Hi,
I have a Datatable displaying data from JSON.
Datatable displays different rows and a button inside those rows.
I need data of each row on button click from that row.
Here is my code.
$(document).ready(function() {
var oTable = $("#DoctorsDisplayTable").dataTable( {
"bProcessing": false,
"bServerSide": false,
"sort": "position",
"sAjaxSource": "/appointment/PaginationServlet",
"aoColumns": [
{ "mData": "image" },
{ "mData": "name" },
{ "mData": "speciality" },
{ "mData": "qualification" },
{"defaultContent": "<button>Book!</button>"},
]
} );
} );
Here is what I am trying to do to get data. Now in the below code if I try to get aData[0]. it gives undefined.
$('#DoctorsDisplayTable tbody').on( 'click', 'button', function () {
var aData = oTable.fnGetData($(this).parents('tr')[0]);
alert("This is alert"+aData);
return false;
} );} );
Any help will be appreciated..
Thanks in advance!!!
Replies
Finally got response.!!!
var $row = $(this).closest("tr"),
$tds = $row.find("td");