When I set info to false: Uncaught TypeError: Cannot read property 'length' of undefined.. happens

When I set info to false: Uncaught TypeError: Cannot read property 'length' of undefined.. happens

bjlapbjlap Posts: 29Questions: 11Answers: 1

Hi,
I noticed that when I set the info property (that display info in the footer) on a DataTable to false, I am getting an error in the Editor functionality: Uncaught TypeError: Cannot read property 'length' of undefined..
So for the time being I keep this property set to true..
Does anyone know why this happens? I want to set it to false because I have a scenario with very little data and I want the page to be as clean as possible (without displaying unnecessary info).
Thanks,
Bert-Jan

Answers

  • allanallan Posts: 61,663Questions: 1Answers: 10,094 Site admin

    Can you give me a link to the page please? I've just tried it locally and haven't been able to reproduce the error I'm afraid.

    Thanks,
    Allan

  • DixensDixens Posts: 4Questions: 0Answers: 0

    Same thing here

    Thanks.

  • tangerinetangerine Posts: 3,348Questions: 36Answers: 394

    If you mean "same problem", then obviously Allan's answer applies to you too.

  • DixensDixens Posts: 4Questions: 0Answers: 0

    No specific code here + Extranet.

    In a nutshell:

    $('#example').DataTable( {
    paging: false
    } );

    => no issue

    $('#example').DataTable( {
    info: false
    } );

    => "Uncaught TypeError: Cannot read property 'length' of undefined"

    Thanx.

  • kthorngrenkthorngren Posts: 20,274Questions: 26Answers: 4,765
    edited March 2017

    This example works:
    http://live.datatables.net/nehociko/1/edit

    The init code:

      var table = $('#example').DataTable( {
        ajax: '/ajax/arrays.txt',
        info: false
      } );
    

    What is needed is a link to your non-working page or to a test case showing the issue. Otherwise there is not enough info to troubleshoot. Possibly providing debugger info may help.

    Typically that error means the number of table columns doesn't match the number of data elements return for each row.

    Kevin

  • DixensDixens Posts: 4Questions: 0Answers: 0

    Thank you for your quick reply.

    I understand this means the number of table columns doesn't match the number of data elements. As I can't link to the private page, I'll get back to you with a JS Fiddle soon.

    If I find the origin of the issue in the meantime (first time I come across and been using DT for years), I'll post it here of course.

    Thank you for your time.

  • DixensDixens Posts: 4Questions: 0Answers: 0

    Can't reproduce the bug in a JS Fiddle. Bug is still present in all tables in our app though:

    info:true is OK (displaying relevant data e.g Showing 1 to 10 of 57 entries)
    info:false returns the infamous "Uncaught TypeError: Cannot read property 'length' of undefined"

    So can't tell, really. But found a workaround by setting the info label to void:

    info:true,
    language: {
    "info": '',
    }

    Thanx again for your previous answers.

  • allanallan Posts: 61,663Questions: 1Answers: 10,094 Site admin

    Its probably related to the data that is being fed into the table. But really without being able to see a test case there isn't much we can do to be able to help fix it.

    Good you have a workaround though.

    Allan

This discussion has been closed.