DataTable - ColumnToggler ColumnToggler is a helper component of datatable to toggle the visibility of columns.
List of Cars
IdYearBrandColorPrice
892b8d251984HondaRed$1,527.00
85d2595d1993VolvoRed$84,396.00
3857f9c71961AudiMaroon$57,519.00
a97e62ed1972HondaBlue$91,661.00
7b44458e2003FiatWhite$34,427.00
e219df021991BMWSilver$70,627.00
b6aea9f51975MercedesWhite$83,188.00
ff3036791986VolkswagenSilver$75,560.00
727be94a1970FordGreen$10,328.00
0444acd51997MercedesYellow$46,206.00
<p:dataTable id="cars" var="car" value="#{dtBasicView.cars}">
    <f:facet name="header">
        List of Cars

        <p:commandButton id="toggler" type="button" value="Columns" style="float:right" icon="ui-icon-calculator" />
        <p:columnToggler datasource="cars" trigger="toggler" />
    </f:facet>

    <p:column headerText="Id">
        <h:outputText value="#{car.id}" />
    </p:column>

    <p:column headerText="Year">
        <h:outputText value="#{car.year}" />
    </p:column>

    <p:column headerText="Brand">
        <h:outputText value="#{car.brand}" />
    </p:column>

    <p:column headerText="Color">
        <h:outputText value="#{car.color}" />
    </p:column>

    <p:column headerText="Price">
        <h:outputText value="#{car.price}">
            <f:convertNumber type="currency" currencySymbol="$" />
        </h:outputText>
    </p:column>
</p:dataTable>
                
PrimeTek, Copyright © 2015
All rights reserved.
Running PrimeFaces-6.1-SNAPSHOT on Mojarra-2.2.8.