Update number of rows displayed based on table/container height?

Update number of rows displayed based on table/container height?

bt1bt1 Posts: 3Questions: 0Answers: 0
edited July 2013 in General
Hello all,

First would like to thank the developer of DataTables for such a great script!

I'm creating an app where I would like the number of rows that are displayed in the table to change based on the height of the table (and its container). I am using pagination, and do not want any vertical (or horizontal) scrollbars to ever appear.

In other words, when the user resizes their browser to a smaller size, less rows would be displayed per "page". And when the user resizes their browser to a larger size, more rows will be displayed per page. So basically, the rows should always fill up the height of the browser screen (provided of course that there are enough row records to do so).

I've searched the documentation and the forum for a few hours now, but couldn't find any information regarding how to do this. Perhaps I've overlooked something obvious?

Anyways, here's a simple test page I've set up (it's incomplete, obviously, but maybe it will help someone know how to provide the best solution)...

http://www.thebestinfo.org/datatables/test.html

Thanks!

Replies

  • bt1bt1 Posts: 3Questions: 0Answers: 0
    Anyone?
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Sounds like a nice idea. Currently, no there isn't a built in way of doing this, but it could readily be done with the fnLengthChange API plug-in and a little calculation and DOM manipulation, the first to get the height of the rows in the table and the available height of the window and the second to set the height of the container and change the table length.

    Sounds like a good topic for a future blog post (although it will be after 1.10 is released as things are currently going).

    Regards,
    Allan
  • bt1bt1 Posts: 3Questions: 0Answers: 0
    Thanks for your reply, Allan. :) I'll look into your suggestion.
This discussion has been closed.