DataTable - ColumnToggler

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

Documentation
List of Cars
IdYearBrandColorPrice
22f8e1f61995FiatBrown$11,475.00
4065be5a1986FordGreen$84,633.00
5ed7629e1989HondaRed$6,444.00
6c2b681f1967MercedesBlue$75,242.00
2046d66d1967BMWRed$53,583.00
87b80d891979VolkswagenBrown$53,152.00
44eef39b1969RenaultRed$42,882.00
4af2afc11975RenaultMaroon$91,748.00
96f163f21990RenaultWhite$82,029.00
6f2d749e2008BMWRed$27,112.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.