scrollX and scrollY cause error

scrollX and scrollY cause error

rottenrotten Posts: 14Questions: 4Answers: 1

When I enable scrollX, or set scrollY: 300, my table fails to render. Instead it throws this error:

"Uncaught TypeError: Cannot read property 'sWidth' of undefined"

I've compared this table to a couple of others where I used those values successfully and cannot figure out why enabling either of those parameters causes it to throw that error. Would it matter that this table is in a

<

div> and the other two are not?

This question has an accepted answers - jump to answer

Answers

  • rottenrotten Posts: 14Questions: 4Answers: 1

    I'm using 1.10.7, and it is throwing this error on line 3845 in the jquery.dataTables.js file.

  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin

    Can you try the 1.10.8-dev nightly from the downloads page please?

    Failing that, can you link to a test case, as required in the forum rules please.

    Allan

  • rottenrotten Posts: 14Questions: 4Answers: 1

    Gave it a try. Not much luck. Sent you a message with a link to the page that is failing when either of those options is enabled. Meanwhile, I'll see if I can set up a test case that I can make public to post here.

  • rottenrotten Posts: 14Questions: 4Answers: 1

    I'm still stumped on this. I have not been able to reproduce it outside of the context of that one page where it is being thrown. I'm still working on coming up with a reproducible example to share.

    Setting autoWidth to false does not help.

    With scrollX or scrollY enabled, it always chokes on line 3850 of the 1.10.8-dev branch.

  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin
    Answer ✓

    Just replied by PM.

    Allan

  • rottenrotten Posts: 14Questions: 4Answers: 1

    This error shows up when there are more columns in the table than columns in the dataTable definition.

    ie -

    <th></th><th></th><th></th>
    gives us three columns in the table.

    But then in dataTables (
    columns: [ { data: "col_1" }, {data: "col_2"} ] )

    We've only defined 2 of them.

    If you turn on scrollX or scrollY, it will get confused and may throw an error when it tries to calculate the various column widths.

This discussion has been closed.