DataTable - ColumnToggler

ColumnToggler is a helper component of datatable to toggle the visibility of columns.

Documentation
List of Cars
IdYearBrandColorPrice
815c04b61996RenaultBrown$38,418.00
0f6ee2b02004RenaultBlue$59,179.00
f82d6f4c1968MercedesRed$58,348.00
50d069431987FiatGreen$98,516.00
8ea552382001AudiBlack$27,628.00
0a1272072005HondaMaroon$74,428.00
75b00ede1969HondaGreen$82,388.00
63d3d68c1995VolvoRed$38,981.00
1929cd0b1979AudiRed$28,740.00
faffba4a1975FiatRed$21,282.00
<style type="text/css">
    .ui-datatable-header {
        height: 50px
    }
</style>


<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="pi pi-align-justify" />
        <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>

FREE THEMES

Built-in component themes created by the PrimeFaces Theme Designer.

nova-light Nova-Light
nova-dark Nova-Dark
nova-colored Nova-Colored
luna-blue Luna-Blue
luna-amber Luna-Amber
luna-green Luna-Green
luna-pink Luna-Pink
omega Omega

PREMIUM TEMPLATES

Create awesome applications in no time using the premium templates and impress your users.