有没有办法删除p:datatable标题上的全选复选框。
我需要单独行上的复选框,但不需要在标题上。
答案 0 :(得分:7)
这非常有效:
.ui-chkbox.ui-chkbox-all.ui-widget {
display:none !important;
}
答案 1 :(得分:5)
您可以做的是:
在default.css文件中添加以下内容:
.table-no-select-all .ui-chkbox-all {
display: none !important;
}
然后在你的小册子中,请参考下面的内容:
<h:form id="form">
<p:dataTable id="cars" rowIndexVar="idx" styleClass="table-no-select-all" ...>
<p:column selectionMode="multiple" style="width:2%" />
</p:dataTable>
</h:form>
感谢。
答案 2 :(得分:2)
我设法通过使用p:columnGroup来指定标题。
<p:dataTable id="selectByPotentialTable" var="replacementByPotential"
widgetVar="selectByPotentialTable"
value="#{kmSelectByPotentialBean.allReplacementPrintersViewModel}"
selection="#{kmSelectByPotentialBean.selectedByPotentialReplacement}">
<p:columnGroup type="header">
<p:row>
<p:column/>
<p:column headerText="Printer Model"/>
</p:row>
</p:columnGroup>
<p:column selectionMode="multiple" style="width:2%;text-align:center"/>
<p:column>
#{replacementByPotential.name}
</p:column>
</p:dataTable>
如果您改变主意并希望显示selectAll复选框,则需要更改
<p:columnGroup type="header">
<p:row>
<p:column/>
<p:column headerText="Printer Model"/>
</p:row>
</p:columnGroup>
到
<p:columnGroup type="header">
<p:row>
<p:column selectionMode="multiple" style="width:2%;text-align:center"/>
<p:column headerText="Printer Model"/>
</p:row>
</p:columnGroup>
答案 3 :(得分:1)
例如:
<h:form id="form">
<p:dataTable id="cars" rowIndexVar="idx" ...>
<p:column selectionMode="multiple" style="width:2%" />
</p:dataTable>
</h:form>
Primefaces将默认后缀_head
添加到datatable的标题中,例如:datatable的标题将包含id cars_head,因此您可以通过css禁用select all checkbox
.ui-chkbox-box.ui-widget.ui-corner-all.ui-state-default
是数据表中所有复选框的复选框样式。
如果您使用JSF 2.0
:
<style type="text/css">
#form-cars_head .ui-chkbox-box.ui-widget.ui-corner-all.ui-state-default{
display:none !important;
}
</style>
您需要将此配置添加到web.xml
才能使用&#39; - &#39;在组件的id:
<context-param>
<param-name>javax.faces.SEPARATOR_CHAR</param-name>
<param-value>-</param-value>
</context-param>
答案 4 :(得分:1)
这适用于Primefaces 6.0
var comment = document.createComment('[if mso]> <v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="http://www.EXAMPLE.com/" style="height:40px;v-text-anchor:middle;width:300px;" arcsize="10%" stroke="f" fillcolor="#d62828"> <w:anchorlock/> <center style="color:#ffffff;font-family:sans-serif;font-size:16px;font-weight:bold;"> Button Text Here! </center></v:roundrect><![endif]'); document.querySelector("html").append(comment);