scrollX and scrollY cause error
scrollX and scrollY cause error
rotten
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
This discussion has been closed.
Answers
I'm using 1.10.7, and it is throwing this error on line 3845 in the jquery.dataTables.js file.
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
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.
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.
Just replied by PM.
Allan
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.