Uncaught TypeError: Cannot read property 'length' of undefined

Uncaught TypeError: Cannot read property 'length' of undefined

crawln45crawln45 Posts: 8Questions: 0Answers: 0
edited May 2013 in DataTables 1.9
Just wondering if anyone has any idea why this is happening.
http://home.mybluebox.net/mymovies/

Uncaught TypeError: Cannot read property 'length' of undefined jquery.DataTables.js:2107

happens when I type in anything in the genres column.

Replies

  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    I don't see a genres column I'm afraid?

    Allan
  • crawln45crawln45 Posts: 8Questions: 0Answers: 0
    edited June 2013
    It's pulled with the aaData. But not displayed until a row is Clicked. That's not the problem. The problem is it's not showing 0 records to display. Thinking it has something to do with the server side processing not retruning aaData at all because there's nothing there to put into the array. Just not sure how to fix it.
  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    I'm a little confused I'm afraid. The table, when I load the page, shows 10 rows. If I click on 'A Good Day to Die Hard', a 'details' section opens. I don't see any errors.

    > The problem is it's not showing 0 records to display

    You are expecting it to show 0 records on page load?

    Allan
  • crawln45crawln45 Posts: 8Questions: 0Answers: 0
    Allen yes when you search and there not be any records It should show No records found. But instead it errors out with property length. Even though I set the 0 records display on it. But i think it may have something to do with the aaData being sent from the server side processing. Seeing as it doesn't return a json aaData string if there's nothing found.
  • crawln45crawln45 Posts: 8Questions: 0Answers: 0
    My assumption was that it read the iTotaldisplayrecords first so that if aaData was not present it would see that there's 0 records to display and would generate the 0 records to display message.
  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    > Seeing as it doesn't return a json aaData string if there's nothing found.

    That would do it. DataTables expects an empty array if there are no records. Are you able to modify the returned json? If not you'd need to use fnServerData to make your own Ajax call and then reformat the returned json.

    Allan
  • crawln45crawln45 Posts: 8Questions: 0Answers: 0
    I can modify the json. if i know how to return an empty array for json. looking into any help would be appreciated.
  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    > if i know how to return an empty array for json

    Its simply `[]` . In PHP `echo json_encode( array() );` . Other languages will be different.

    Allan
  • crawln45crawln45 Posts: 8Questions: 0Answers: 0
    well since I'm using the the stock server_processing i added the array to the $object to start.
This discussion has been closed.