Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Masking numbers in PrimeFaces footerText column Datatable

I want to display a masked number like this: 1.234.567,89. The following code already do this:

<p:column>
    <h:outputText value="#{item.value}">
      <f:convertNumber locale="pt_BR"/>
    </h:outputText>
</p:column>

How can I applly the same mask for a Primefaces datatable in a footerText column as the following code excerpt?

<p:columnGroup type="footer">  
  <p:row>  
    <p:column colspan="8" footerText="Grand Total:" />  
    <p:column footerText="#{upbController.totalLosses}" />      
  </p:row>  
</p:columnGroup>

Thanks in advance.

like image 259
jMarcel Avatar asked Nov 05 '13 15:11

jMarcel


1 Answers

You can try to place your footerText using f:facet. Here is how I used to use it for p:column:

<p:column headerText="Number of units" >
    <h:outputText value="#{item.units}" />
    <f:facet name="footer">
        <h:outputText
            value="Total: #{mybean.unitsTotal}" />
        <br />
        <h:outputText
            value="To do: #{mybean.unitsTodo}" />

    </f:facet>
</p:column>

I suspect that it would work also for p:columnGroup and then you can apply f:convertNumber to such h:outputText.

Update

And here's how works for header facet in header type:

<p:columnGroup type="header">
    <p:row>
        <p:column rowspan="2" headerText="Manufacturer" />
        <p:column colspan="2">
            <f:facet name="header">
                <h:outputText value="#{bean.countValue(bean.order)}">
                    <f:convertNumber maxFractionDigits="2" minFractionDigits="2" currencyCode="PLN" locale="pl_PL" />
                </h:outputText>
            </f:facet>
        </p:column>
    </p:row>
</p:columnGroup>

and for footer facet in footer type:

<p:columnGroup rendered="true" type="footer">
    <p:row>
        <p:column rowspan="2" headerText="Manufacturer" />
        <p:column colspan="2">
            <f:facet name="footer">
                <h:outputText value="#{bean.countPieces(bean.order)}">
                    <f:convertNumber pattern="###,###.00" locale="pl_PL"/>
                </h:outputText>
            </f:facet>
        </p:column>
    </p:row>
</p:columnGroup> 
like image 197
ppawel Avatar answered Oct 20 '22 07:10

ppawel