Search code examples
jsfjsf-2primefacescss

PrimeFaces datatable Scrollbar


I have a form with a primefaces datatable which i have set the columns width in css for it :

.idcol{width: 5%}
.prioritycol{width: 5%}
.titlecol{width: 30%}
.descriptioncol{width: 40%}
.actionscol{width: 10px}

Everything is okay but when i add the scrollable="true" attribute in order to have a scrollable datatable, the result is worst :

enter image description here

This is the declaration of the datatable :

<p:dataTable  id="dtable" var="todos" value="#{todo.todoList}" scrollable="true" 
                             resizableColumns="false" scrollHeight="300" lazy="true"
                             styleClass="idcol,prioritycol,titlecol,descriptioncol,actionscol">

What is the problem? Thank you!


Solution

  • I found the solution, You have to edit you css and you JSF code at the same time and looking what you have as result, For my problem i edited my css and the jsf code step by step, here is the code that worked for me :

    CSS :

    .idcol{width: 5%}
    .prioritycol{width: 5%}
    .titlecol{width: 30%}
    .descriptioncol{width: 40%}
    .actionscol{width: 20%}
    

    The Form :

    1. Column 1 : width="25"
    2. Column 2 : width="55"
    3. Column 3 : width="369"
    4. Column 4 : width="469"
    5. Column 5 : width="170"