Scroller plugin issue (rowHeight calculation)
Scroller plugin issue (rowHeight calculation)
abrahamD
Posts: 3Questions: 0Answers: 0
Hi,
I am currently developing with Datatables and having an issue with the Scroller plugin. I am trying to set it up for a table of statically sized rows of multiple lines. I am aware of the documentation warnings about the later but was wondering how it affected the plugin since all the rows remain at the same height.
I am currently developing with Datatables and having an issue with the Scroller plugin. I am trying to set it up for a table of statically sized rows of multiple lines. I am aware of the documentation warnings about the later but was wondering how it affected the plugin since all the rows remain at the same height.
This discussion has been closed.
Replies
The reason it needs to know the rowHeight is because that number will be used in conjunction with the viewport height to determine how many rows to display on a single "page". Let's assume the rowHeight gets set to 20px and it knows that the viewport height is 600px, that means that there is a maximum of 30 rows which can be displayed at a time. I believe it provides an additional 50% buffer of rows above and below the 30 rows on screen, meaning there would be a total of 60 rows in the DOM (15 above and 15 below).
It also uses that number to calculate when to redraw a new "page" of table data. It already knows you can fit 30 visible rows in the viewport, so once you scroll 15 rows (rowHeight * 15 = 300px) it will tell your DataTable to render the next "page" of rows from the table.
The rowHeight value is used everywhere in the Scroller plugin. Even the scrollbar you see is faked by generating a 1px wide div whose height is set to (totalNumberOfRows * rowHeight).
I noticed after posting this thread that others had the same issue, and stumbled upon this post:
http://datatables.net/forums/discussion/10131/scroller-breaks-rowheight/p1
After updating the code to what WingedFox suggested, it ended up working. I guess that'll have to do until a fix is pushed.
Thanks for the response anyway,
Allan