DataTable - Resizable Columns

DataTable columns can be resized by dragging. Optional "colResize" ajax behavior can be used to get notified about new column widths.

Basic Resize

Model
Year
Manufacturer
Color
566c7f55
1987
Audi
Brown
0e795d2b
1984
BMW
Green
8abc856a
1961
Renault
Blue
f702b293
1960
Renault
Orange
70b17e53
1976
BMW
Silver
3033d229
1977
Audi
Yellow
66c0c48c
1964
Audi
Red
15294b2d
1971
Volkswagen
Yellow
cf88451d
2008
Ford
Orange

Ajax Resize

Model
Year
Manufacturer
Color
566c7f55
1987
Audi
Brown
0e795d2b
1984
BMW
Green
8abc856a
1961
Renault
Blue
f702b293
1960
Renault
Orange
70b17e53
1976
BMW
Silver
3033d229
1977
Audi
Yellow
66c0c48c
1964
Audi
Red
15294b2d
1971
Volkswagen
Yellow
cf88451d
2008
Ford
Orange

Source

<h:form id="form">
                    
    <p:growl id="growl" showDetail="true"/>

    <h3>Basic Resize</h3>
    <p:dataTable var="car" value="#{tableBean.carsSmall}" resizableColumns="true" id="basicTable">
        <p:column headerText="Model" style="width:125px" id="model">
            #{car.model}
        </p:column>

        <p:column headerText="Year" style="width:125px" id="year">
            <h:outputText value="#{car.year}" />
        </p:column>

        <p:column headerText="Manufacturer" style="width:125px" id="manufacturer">
            <h:outputText value="#{car.manufacturer}" />
        </p:column>

        <p:column headerText="Color" style="width:125px" id="color">
            <h:outputText value="#{car.color}" />
        </p:column>
    </p:dataTable>

    <h3>Ajax Resize</h3>
    <p:dataTable var="car" value="#{tableBean.carsSmall}" resizableColumns="true" id="ajaxTable">

        <p:ajax event="colResize" update=":form:growl" listener="#{tableBean.onResize}" />

        <p:column headerText="Model" style="width:125px" id="model">
            #{car.model}
        </p:column>

        <p:column headerText="Year" style="width:125px" id="year">
            <h:outputText value="#{car.year}" />
        </p:column>

        <p:column headerText="Manufacturer" style="width:125px" id="manufacturer">
            <h:outputText value="#{car.manufacturer}" />
        </p:column>

        <p:column headerText="Color" style="width:125px" id="color">
            <h:outputText value="#{car.color}" />
        </p:column>
    </p:dataTable>

</h:form>