Search code examples
jsfrichfaces

JSF - scrolling datatable


I've used this BalusCs guide to view and paging datatables. It's very nice and useful guide (where would I be without it?), but I have one more question (maybe directly for you, BalusC):

Is there some posibility to scroll datatable horizontally and mainly vertically (without moving a headers)?

Thank you

EMERGENCY SOLUTION (using HTML):

place <h:form> to <div id="scrolltable">

and define scrolltable in css, for example:

#scrolltable{
  width: 920px; height: 300px;
  overflow-y: scroll;
  overflow-x: auto;
}

Solution

  • This is not directly possible in HTML and therefore also not with the standard set of JSF components. You would need to bring in a lot of specific CSS/JS works. That's too much of detail and pain to summarize in a single answer.

    However, there exist 3rd party JSF component libraries which offers that in a single ready-to-use component. For example PrimeFaces and RichFaces 4.x (and RichFaces 3.x) have scrollable datatable components which are even able to fetch new rows by ajax. Since you tagged the question with richfaces, you should be able to use the RichFaces' one.