"ReferenceError: table is not defined" and ""Uncaught TypeError: table.row is not a function"

"ReferenceError: table is not defined" and ""Uncaught TypeError: table.row is not a function"

bvelasquezbvelasquez Posts: 28Questions: 7Answers: 0

It seems that if you use "dataTable" instead of "DataTable" during initialization, you will get an error when you try to access it later.

For example:

datatables_viewer = $('#myTable').dataTable({...}); // Note lower-case "D"

datatables_viewer.on( 'click', 'tr', function (){
    // Get the rows id value
    currentlySelectedId = datatables_viewer.row( this ).id();
    console.log("Currently Selected ID: " + currentlySelectedId);
});

Will not work, returning an error of:

"Uncaught TypeError: datatables_viewer.row is not a function"

But changing the "d" to an uppercase solves the issue.

Thanks to these posts to help me figure out the issue.

https://datatables.net/forums/discussion/comment/87890/#Comment_87890
https://datatables.net/forums/discussion/comment/76389/#Comment_76389

I thought "dataTable" was the new naming convention?

Replies

  • bvelasquezbvelasquez Posts: 28Questions: 7Answers: 0

    Found the doc where it mentions the name change:

    https://datatables.net/manual/installation#Initialising-DataTables

    "Upgrade note:
    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.

    Please refer to the API manual for further information."

  • rockingsatish18rockingsatish18 Posts: 2Questions: 0Answers: 0

    Please remove bootstrap

    <

    div class="col-sm-4"> like "col-sm...."

  • rockingsatish18rockingsatish18 Posts: 2Questions: 0Answers: 0

    in outer level

This discussion has been closed.