Error When Trying to Get Selected Row Values: Cannot read property '_aData' of undefined

Error When Trying to Get Selected Row Values: Cannot read property '_aData' of undefined

datatabledudedatatabledude Posts: 2Questions: 1Answers: 0

I'm unable to determine why I'm receiving the error of "Uncaught TypeError: Cannot read property '_aData' of undefined"

var table = $('#example').DataTable();

$('#example tbody').on('click', 'tr', function () {                           
   var data = table.row(this).data();                            
   console.log(table.rows(this).data());

Any thoughts or pointers?

Answers

  • datatabledudedatatabledude Posts: 2Questions: 1Answers: 0

    I forgot to post this as well....

    $('#example').DataTable({
                                select: true,
                                paging: false,
                                serverSide: false,
                                processing: false,                            
                                ajax: {                                
                                    url: '/GetStudentRandom/' + term + '/' + section,                                        
                                    type: "GET",
                                    dataType: "json",                                
                                    dataSrc: function (d) {
                                        return d[0].data
                                    },                                
                                },                            
                                columns: [
                                    { "data": "facultyID" },
                                    { "data": "facultyTerm" },
                                    { "data": "facultySecNo" },
                                    { "data": "secNo" },
                                    { "data": "facultySecName" },
                                    { "data": "facultyUsername" },
                                    { "data": "studentRandomID" },
                                    { "data": "letterGrade"}                                       
                                ]
    
                            });
    
  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @datatabledude ,

    It's probably because of the second line:

       var data = table.row(this).data();                           
       console.log(table.rows(this).data());
    

    You'll see the logging is using rows(), and not row() as the assignment is. Try changing that and see if that helps,

    Cheers,

    Colin

This discussion has been closed.