DataTable gets tr data

I created a table with a jQuery plugin for dataTable. I am trying to get the td data of a tr element by clicking on this tr. I read the documentation that says I need to use "fnGetData", but when I try to do this, I get an error message:

TypeError: table.fnGetData is not a function

var data = table.fnGetData (this);

My js code is:

 $('#customerTable tbody').on('click','tr', function(){
    var data = table.fnGetData( this );
    alert(data);
});

My DataTable is initialized as follows, working well without the click event:

var table = $('#customerTable').DataTable( {..});

Do I need to link another script plugin in the html head section?

Sincerely.

+4
source share
1 answer

, API- , DataTable({..}) vs DataTable({..}). .

API, .

var data = table.row( this.rowIndex-1 ).data();

DataTable({..}) , , , .

+4

Source: https://habr.com/ru/post/1544807/


All Articles