How to value of hidden td from a row on button click in datatable?
How to value of hidden td from a row on button click in datatable?
deeptierx
Posts: 5Questions: 0Answers: 0
Hi,
I need to know how do I get value of hidden TD displayed in row on button click in that row. I am currently able to get valued of only displayed TD in data. I need value of id also while retrieving values of 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>"},
{"mData":"doctorId" ,"bSearchable": true, "bVisible": false},
]
} );
$('#DoctorsDisplayTable tbody').on( 'click', 'button', function () {
var $row = $(this).closest("tr"), // Finds the closest row <tr>
$tds = $row.find("td"); // Finds all children <td> elements
var arr = [];
i = 0;
$.each($tds, function() {
arr[i++] = $(this).text();
// Prints out the text within the <td>
});
alert("data"+arr[5]);
});
} );
HTML:-
<tr><th>Image</th>
<th>Name</th>
<th>Specialty</th>
<th>Qualification</th>
<th>Book!</th>
<th>ID</th>
</tr>
Any help would be appreciated.
Thanks!
This discussion has been closed.