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?

deeptierxdeeptierx Posts: 5Questions: 0Answers: 0
edited February 2015 in Free community support

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

  • deeptierxdeeptierx Posts: 5Questions: 0Answers: 0

    Finally got response.!!!

    var $row = $(this).closest("tr"),
    $tds = $row.find("td");

    $.each($tds, function() {           
    alert("TD::"+($(this).text()));        
    });
    
This discussion has been closed.