DataTable - Sorting

DataTable has built-in support for ajax sorting.

Ajax Sorting
ModelYearManufacturerColor
6756d1a81969OpelMaroon
9ac867ee1994FordOrange
1189862e1975VolvoYellow
cc51ffc51982FordGreen
19556df41980FordWhite
ef910aec2005FordBlue
78b085b52003HondaOrange
4d48efbc1983FordBrown
810c03c31962FordBrown

Source

<h:form>

    <p:dataTable id="dataTable" var="car" value="#{tableBean.carsSmall}">
        <f:facet name="header">
            Ajax Sorting
        </f:facet>

        <p:column sortBy="model" headerText="Model">
            <h:outputText value="#{car.model}" />
        </p:column>

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

        <p:column sortBy="manufacturer" headerText="Manufacturer">
            <h:outputText value="#{car.manufacturer}" />
        </p:column>

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

</h:form>