0

This is my code which I am using for my DataTable :

  var oTable12= $('#example').DataTable({
       "aaData": tableData,
       "aLengthMenu": [[5, 10, 20, -1], [5, 10, 20, "All"]],
       "iDisplayLength": 5,
       "aoColumnDefs" :tableColumn
       });

I am adding column headers and default content in tableColumn array and then using it in aoColumnDefs .

I am getting perfect UI as it is expected, but when I click the button I get the following error :

Uncaught ReferenceError: table is not defined

This is my code for button click :

    $('#example tbody').on( 'click', 'button', function () {
      var data = oTable12.row(0).data();
      alert( data);
    } );

Thank you

3 Answers 3

1

change your table to oTable12

  var data = table.row(0).data();

to

  var data = oTable12.row(0).data();

see if this works for you :)

Sign up to request clarification or add additional context in comments.

10 Comments

Uncaught ReferenceError: table is not defined This is what I am getting after making changes as follows : var data = oTable12.row(0).data();
can you update the question with all the changes you did
how can you get table as undefined when it doesnt not even exists in your code
i recommend rechecking for the changes where are you making your changes
I don't know actually I am learning Datatables so while following the examples I encountered this error
|
0

Because table is not defined in your current context.Replacing table with oTable12 will do trick for you.

Comments

0

Finally solved :

This was due to version problem, now I downloaded the latest version and now it is working correctly

Thank you to all of you for your precious reply and support

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.