DataTable - Dynamic Columns

Columns of datatable can be created dynamically using the p:columns component.

Documentation
Available columns are "id","brand","year","color" and "price".
IDBRANDYEAR
06de4c7dFiat1965
c30bc589BMW1999
013e001fVolkswagen1980
a30383b1BMW1971
9be7d182Renault1984
60e10fe6Audi1960
cb66a882Volvo2004
f08e6e51Ford1977
f74e1a64Ford1999
4d16d0d3Volvo2002
Available columns are "id","brand","year","color" and "price".

<h:form id="form">    
    <h:panelGrid columns="3" style="margin:10px 0">
        <p:outputLabel for="template" value="Template:" style="font-weight:bold"/>
        <p:inputText id="template" value="#{dtColumnsView.columnTemplate}" size="50"/>
        <p:commandButton update="cars" action="#{dtColumnsView.updateColumns}" value="Update" process="@parent" icon="pi pi-refresh" oncomplete="PF('carsTable').clearFilters()"/>
    </h:panelGrid>

    <p:dataTable id="cars" var="car" value="#{dtColumnsView.cars}" widgetVar="carsTable" filteredValue="#{dtColumnsView.filteredCars}">                    
        <p:columns value="#{dtColumnsView.columns}" var="column" columnIndexVar="colIndex" sortBy="#{car[column.property]}" filterBy="#{car[column.property]}">
            <f:facet name="header">
                <h:outputText value="#{column.header}" />
            </f:facet>
            <h:outputText value="#{car[column.property]}" />
        </p:columns>
    </p:dataTable>
</h:form>

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.