fnRowSelected is not working as expected

fnRowSelected is not working as expected

shajishaji Posts: 4Questions: 2Answers: 0

Hi friends,

Please find my code below. I am not sure why fnRowSelected is not working. I am not getting any alert while selecting a row.

Any help on this very much appreciated.

try
                {

                    var pdlJsonObj = output.aaData;

$('#divDataTable').dataTable(
{
"aaData": pdlJsonObj,
"bDestroy": true,
"sPaginationType": "full_numbers",
"bPaginate": true,
"bFilter": true,
"aLengthMenu": [
[5, 10, 25, 50],
[5, 10, 25, 50]
],
"bFilter": true,
"aaSorting": [],
"tableTools": {
"sRowSelect": "single",
"fnRowSelected": function ( node ) {
alert( 'The row with ID '+node[0].id+' was selected' );
}
},
"fnCreatedRow": function (nRow, aData, iDisplayIndex, iDisplayIndexFull)
{

                                    $(nRow).attr('id', iDisplayIndex);
                                    },
                     "fnInitComplete": function ()
                                    {
                            $('#divDataTable tbody tr').find('td').removeClass('markrow'); //To Remove Highlight from Other Rows when we select a row
                                      $("#divDataTable tbody tr:eq(0)").find('td').each(function ()
                                          {
                                            $(this).addClass("markrow");
                                           });                  
                            }

                    });

                }

                catch(err)
                {
                    alert(err.message);
                    // document.getElementById('divLoading').innerHTML = err.message;
                }

            });

Thanks
Shaji

Answers

  • shajishaji Posts: 4Questions: 2Answers: 0

    My data table version is 1.9.2

  • shajishaji Posts: 4Questions: 2Answers: 0
    edited January 2015

    Hi

    Below code resolved the issue. I think it was an issue with version. I think fnRowSelected is not supported on version 1.9.2

    $("#divDataTable").on('click', 'tr', function () {
    

    var oTable = $('#divDataTable').dataTable();
    var data = oTable.fnGetData( this );

        alert(data);
    
                });
    
This discussion has been closed.