11

Is there a way to remove the select all check box on the header of the p:datatable.

I need check box on the individual row but not on the header.

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
KCP
  • 312
  • 1
  • 7
  • 18

6 Answers6

9

This works very well :

.ui-chkbox.ui-chkbox-all.ui-widget {
    display:none !important;
 }
Debutantjsf
  • 109
  • 1
  • 5
6

What you can do is below:

Add the below in your default.css file:

.table-no-select-all .ui-chkbox-all {
     display: none !important;
}

And then in your facelet, refer that like below:

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

Thanks.

Sudipta Deb
  • 1,040
  • 3
  • 23
  • 43
3

I managed to do this by using p:columnGroup for specifying headers.

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

If you change your mind and you want the selectAll checkbox to be displayed, you need to change

<p:columnGroup type="header">
        <p:row>
        <p:column/>
           <p:column headerText="Printer Model"/>
        </p:row>
</p:columnGroup>

to

<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>
Zhenya
  • 6,020
  • 6
  • 34
  • 42
1

For example:

<h:form id="form"> 
   <p:dataTable id="cars" rowIndexVar="idx" ...>
     <p:column selectionMode="multiple" style="width:2%" />  
   </p:dataTable>
 </h:form>

Primefaces add default suffix _head to datatable's header, in example: datatable's header will have id cars_head, so you can disable select all checkbox via css .ui-chkbox-box.ui-widget.ui-corner-all.ui-state-default is checkbox's style of all checkbox in datatable.

If you use 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>

you need to add this configuration to web.xml to use '-' in component's id:

    <context-param>
        <param-name>javax.faces.SEPARATOR_CHAR</param-name>
        <param-value>-</param-value>
    </context-param>
Rong Nguyen
  • 4,143
  • 5
  • 27
  • 53
  • I was able to achieve this by overriding .ui-chkbox-all{ display: none !important;} but this is applied to all the all the tables. Is there a way it can be applied to one particular table. – KCP May 08 '13 at 13:25
1

This works for me in PrimeFaces 6.0

.ui-widget-header div.ui-chkbox.ui-widget {
    display: none !important;
}
Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
Fabricio
  • 11
  • 1
0

In PrimeFaces 8.

.ui-datatable .ui-selection-column .ui-chkbox-all {
    display: none !important;
}
Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102