DataTable - ColumnToggler

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

Documentation
List of Cars
IdYearBrandColorPrice
bcbe7be21981VolkswagenMaroon$49,881.00
f424de291985HondaMaroon$28,776.00
066dac182007HondaWhite$35,433.00
a8542c801973HondaWhite$84,837.00
b07206201983HondaBlack$7,498.00
6d4f63661981FordSilver$7,095.00
b8a988721974VolvoBrown$13,680.00
2ca95abb1963FiatOrange$98,596.00
50a9994c1984HondaBlue$44,880.00
ed6b40412007MercedesBlue$30,574.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.