隐藏primefaces表列标题

隐藏primefaces表列标题,primefaces,hide,treetable,columnheader,Primefaces,Hide,Treetable,Columnheader,我有一个p:treeTable,树的内容都在一列中。树是一个共享组件,所以我的一些页面需要列标题,而有些页面不需要。在columnHeader为空的页面中,它为columnHeader创建一个空行,这是我不想要的。我确实想要列内容,但不想要没有列标题时的标题 我怎样才能解决这个问题?任何建议/想法都很好。谢谢 通过将thead display属性设置为none,可以使用自定义CSS解决此问题: 例如: div[id="testForm:first"] thead { display:no

我有一个p:treeTable,树的内容都在一列中。树是一个共享组件,所以我的一些页面需要列标题,而有些页面不需要。在columnHeader为空的页面中,它为columnHeader创建一个空行,这是我不想要的。我确实想要列内容,但不想要没有列标题时的标题


我怎样才能解决这个问题?任何建议/想法都很好。谢谢

通过将thead display属性设置为none,可以使用自定义CSS解决此问题:

例如:

div[id="testForm:first"] thead {
    display:none;
}
如果您的JSF与此类似:

<h:form id="testForm">
    <p:dataTable id="first">
        ...
    <p:/dataTable>
</h:form>

...

您可能会发现您需要更具体地使用样式选择器:

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

这也消除了引用表单id的需要。“$”以通配符开头,“>”表示仅选择直接子项。有关非常好的CSS选择器参考,请参阅。

更正式的解决方案:

标签:

如果您的
使用如下列宽

<p:dataTable styleClass="myTable">
   <p:column width="100">
您还将丢失设置的列宽


隐藏列标题并保持列宽的解决方案

.myTable thead th { 
    border: none !important; 
    background: none !important; 
}
隐藏标题(与其他答案相同):

。。。并指定列宽:

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

这些不适用于reflow=“true”表


对我来说,border:none,background:none建议会在表上方留下一个空白,并隐藏表的左侧边框。

将此代码添加到css3文件中

** 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;
    }
然后从xhtml文件中调用以下代码:

<p:dataTable styleClass="borderless">

感谢您的回答,显示:无对我有效,几乎没有调整以获得所需的行。隐藏列标题表thead tr[role='row']{display:none;}
.hide-table-header thead {
    display: none;
}
<p:dataTable styleClass="hide-table-header">
        <p:column style="width: 80px">
** 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;
    }
<p:dataTable styleClass="borderless">