Alex Rivera | Logout

Set maximum displayed rows count for HTML table

Asked 2010-01-22T13:03:10.493
12

Have JSP page with dynamically generated HTML table with unknown number of rows.

Have property on backend, that sets maximum number of rows, e.g: max_rows=15.

How to limit number of rows for HTML table to max_rows value? Other part of table should be accessible by vertical scroll,it means that user see 15 rows and if to scroll down, that it will be seen other rows of table.

It can be done empirically by calculating average height of row and using max-height property for div-wrapper, but i think this approach is not very stable.

So it's needed to rely on row count. Perhaps there is plugin for such case or it's standard CSS or HTML solution?

Edit
Report

1 Answer

1

There is no way to do this with only CSS and HTML, you need javascript too. Get the height of the top 15 rows, and limit the height of a wrapping div to that height. Set overflow: auto on the div to get your scrollbars.

Don't forget to set a default height on the div as a fallback if javascript is turned off.

answered 2010-01-22T16:35:59.240

Your Answer