File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Scroll bar with data table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Scroll bar with data table" Watch "Scroll bar with data table" New topic

Scroll bar with data table

Ven Red

Joined: Nov 10, 2007
Posts: 6

how can i show the scroll bar for a data table , if it has more than 10 rows? I tried using div tag with style attribute defined some thing like below.

<h:panelgrid ....>
<div style="overflow...blah..blah">
<h:datatable .....>

but my page doen' disply the crollbar...ami missing any thing???
Richard Green
Ranch Hand

Joined: Aug 25, 2005
Posts: 536
this is purely a HTML/CSS issue. I would suggest that you save your screen as HTML (complete) and edit it locally and get the scrollbars working.

After that, you can apply back your changes to the JSF page

MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
V.N.T.Deepak Solasa

Joined: May 29, 2007
Posts: 16
if you can use Richfaces,better you use that in which you have scrollable Data Table tag which makes your work so simpler...

A. Dusi
Ranch Hand

Joined: Sep 27, 2004
Posts: 114
Put your dataTable inside a h:panelGroup and use the style overflow:auto for the latter.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

Apache MyFaces Tomahawk has a data scroller tag that can be paired with a data datable.

This is a page-by-page scroll. If you're looking for an interactive scroll bar, you'll need some sort of AJAX component, instead.

An IDE is no substitute for an Intelligent Developer.
Ranch Hand

Joined: Sep 07, 2007
Posts: 37
Hi all,

I tried several combination.

1) surround the datatable with div tag - scroll bar is not displaying, but it takes the amount of specified width above the data table and that part appears blank.

2) surrounding the Panel grid with div tag - displays the scroll bar, but it takes height starting from table header, column headers and then columns,
which is not good. And also it is taking the specified amount of height even there is no record or less records. I tried giving the percentage of height, then scrollbars not coming.

Can some one help me in resolving the issue??

Thanks in advance.

A. Dusi
Ranch Hand

Joined: Sep 27, 2004
Posts: 114
Looks like you do not want the headers to scroll. In that case you should try separating header and the data into different tables. Use the scrollbar style only for the table showing the data. I remember that this topic was discussed previously in this forum. You may do a search for a better solution.

Also in order to hide the default height of the panelGroup when there are no /less records, you may try two separate panelGroups one with fixed height rendered when there are some specified records and one with no fixed height rendered when there are no/less records.
I agree. Here's the link:
subject: Scroll bar with data table
It's not a secret anymore!