Scroller plugin issue (rowHeight calculation)

Scroller plugin issue (rowHeight calculation)

abrahamDabrahamD Posts: 3Questions: 0Answers: 0
edited May 2012 in DataTables 1.9
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.

Replies

  • jcreadyjcready Posts: 44Questions: 0Answers: 0
    edited May 2012
    I don't understand what you're asking for. I would not recommend manually setting the rowHeight property when initializing the Scroller plugin, as the plugin will automatically calculate the height for you by injecting a element with non-breaking spaces inside each and finding its height().

    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).
  • abrahamDabrahamD Posts: 3Questions: 0Answers: 0
    Yes, I am aware of all that. I was actually referring to the fact that manually setting the rowHeight didn't change row calculation.
    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,
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I've just committed the fix for this and it can be obtained from the 1.0.3.dev nightly: http://datatables.net/download . It will be in 1.0.3 final which isn't too far way.

    Allan
  • abrahamDabrahamD Posts: 3Questions: 0Answers: 0
    Thanks Allan! Great tools and plugins!
This discussion has been closed.