56

I am trying to implement row details in my datatables just like this example.

When I click on the show more image of my table, I get an error in my firebug console saying:

TypeError: oTable.row is not a function
var row = oTable.row(tr);

Here is also a fiddle of my code that generates this error.

As i understand it, the row() function of my datatables is not found. But i don't get it... I use the latest datatables version with jquery version 1.11.1 (and not 1.11.0 as shown in fiddle) which is what is used in the example also(on datatables website).

I am stuck... Anyone has any idea why I get this error?

Thanks a lot

MaVRoSCy
  • 17,747
  • 15
  • 82
  • 125
  • probable duplicate of: http://stackoverflow.com/questions/24510679/datatables-row-is-not-a-function-servers-side-proccessing-row-details – BatScream Sep 02 '14 at 06:47

5 Answers5

160

I don't know what is the difference between dataTable and DataTable functions, but your code worked when I initialized the data table using the second function.

 oTable = $('#tblCasesMain').DataTable({ ...

Here is the fiddle, which only gives an error on format function which is not defined.

Note: I have changed that function name as per this example.

Update: I have done a bit of research and got the answer. Take a look at the Upgrade note here which says the following:

If you are upgrading from DataTables 1.9 or earlier, you might notice that a capital D is used to initialise the DataTable here. $().DataTable() returns a DataTables API instance, while $().dataTable() will also initialise a DataTable, but returns a jQuery object.

Karlen Kishmiryan
  • 7,322
  • 5
  • 35
  • 45
60

There is not need to use .DataTable() instead of dataTable()

Simply append .api(). It will return the object that defines the required row() method.

e.g.: var row = oTable.api().row(tr);

Gustav
  • 53,498
  • 7
  • 29
  • 55
U. Kadner
  • 601
  • 5
  • 2
5

If the above answers don't work in your case, try below alternate.

var row = $('#tblSample').DataTable().row(tr);

Instead of

var oTable =  $('#tblSample').dataTable( {
    //Code
 });
var row = oTable.row(tr);
Praveen Mitta
  • 1,408
  • 2
  • 27
  • 48
3

This is because you haven't mention Function

Check Update Working Link http://jsfiddle.net/2gLqgL7m/7/

user3209031
  • 837
  • 1
  • 14
  • 38
1

Update dataTable() wuth DataTable() No need to use .dataTable()

Use .DataTable()

Example :

oTable = jQuery('#tblCasesMain').DataTable({ ...
Hardik Kalathiya
  • 2,221
  • 1
  • 18
  • 28