Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hide primefaces table column header

I have a p:treeTable and the tree contents are all in one column. The tree is a shared component so some of my pages require column header and and some don't. In the pages where the columnHeader is empty, it creates the an empty row for the column header, which I don't want. I do want the column contents, just not the header when there is no column header.

How can I fix this? Any pointers/ideas would be great. Thanks!

like image 899
santa029 Avatar asked Oct 09 '12 22:10

santa029


2 Answers

You can solved that with custom CSS by setting the thead display attribute to none:

Example:

div[id="testForm:first"] thead {
    display:none;
}

if your JSF is similar to this:

<h:form id="testForm">
    <p:dataTable id="first">
        ...
    <p:/dataTable>
</h:form>
like image 169
Akos K Avatar answered Oct 04 '22 21:10

Akos K


If your <p:dataTable> uses columns widths like this

<p:dataTable styleClass="myTable">
   <p:column width="100">

and you use the following CSS to hide the column headers

.myTable thead {
    display:none;
}

you will also lose the column widths you set


Solution to hide column header and keep column widths

.myTable thead th { 
    border: none !important; 
    background: none !important; 
}
like image 23
Mark Avatar answered Oct 04 '22 21:10

Mark