hide primefaces table column header

一个人想着一个人 提交于 2019-12-05 02:02:57

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>

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; 
}

A more formal solution:

TAG:

<p:treeTable styleClass="tree-table-no-header">

Style:

.tree-table-no-header thead {
    display: none;
}

You may find you need to be more specific with your style selector:

 div[id$="myTableId"]>div>table>thead { display:none; }

This also eliminates the need to reference your form id. The '$' is a starts with wild card and the '>' says select only direct children. See http://www.w3schools.com/cssref/css_selectors.asp for a really good CSS Selector reference.

Hide header (same as other answers):

.hide-table-header thead {
    display: none;
}

... and specify column width:

<p:dataTable styleClass="hide-table-header">
        <p:column style="width: 80px">

These won't work with reflow="true" tables.

For me the border:none, background:none suggestion leaves an empty space above the table and hides the left side border of the table as well.

Add this code to your css3 file

** Remove the header from the dataTable**/
.ui-datatable.borderless thead {
  display: none;
}

/** Remove the border from the dataTable **/
.ui-datatable.borderless tbody,
.ui-datatable.borderless tbody tr,
.ui-datatable.borderless tbody td {
    border-style: none;
    }

Then call this code from the xhtml file like this :

<p:dataTable styleClass="borderless">
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!