Editing Datatable

Editing Datatable

sowmistersowmister Posts: 1Questions: 1Answers: 0
edited March 2015 in Free community support

Hi,

I have a column in my datatable which is an edit icon. Onclick of that icon i wanted to retrieve the row and send a server call.

$('#department tbody').on('click', 'td.details-control', function () {
                        var rowIndex = table.fnGetPosition( $(this).closest('tr')[0] );
                        
    } );

Instead of rowIndex I need the departmentId which is in 3rd column of the dataTable.

Is there a way to do that?

Answers

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin

    Using the new API you would do something like table.row( $(this).closest('tr') ).data() to get the row data and then access column 3 data either as an array or an object, depending on how you configure the table.

    If you need to use the legacy API then fnGetData will get the row's data from the closest tr.

    Allan

This discussion has been closed.