Question

I want to hide the currentPageReportTemplate text when I clicked a button for print. I need only print the image of the datatable.

<p:outputPanel id="outImpresion">
 <p:dataTable scrollable="false" scrollWidth="50%" styleClass="myTable"
                         var="r" value="#{indicePartidaController.listResulIndice}" 
                         sortMode="multiple" rows ="10" paginator="true" 
                         paginatorPosition="bottom" emptyMessage ="No Existe Ningún Dato para esta Consulta">
                         currentPageReportTemplate="Mostrando Partidas del {startRecord} al {endRecord} ">
</p:outputPanel>

<p:commandButton value="Imprimir" icon="ui-icon-print" ajax="false">
                            <p:printer target="outImpresion" />
Was it helpful?

Solution

You can achieve this with CSS @media rules. Just create a @media print rule wherein you put all CSS selectors which should achieve the necessary look'n'feel when the print media is used. The paginator is identified by the ui-paginator classname, so if you just set that to display: none, then it will be hidden in print.

Put this somewhere in a CSS file, generally the bottom is the best place.

@media print {
    .ui-paginator { 
        display: none;
    }
}

Alternatively, you can also use

<h:outputStylesheet name="print.css" media="print" />

with a separate print.css file containing just

.ui-paginator { 
    display: none;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top