DataTable - ContextMenu

ContextMenu has special integration with DataTable.

Documentation
RightClick to View Options
IdYearBrandColor
0eef69fd2003VolkswagenYellow
d6c2b8e41975JaguarYellow
e267e9c61970JaguarBlue
32fbda451986AudiBlue
b1c3cbbd1963VolkswagenSilver
56648b1c1999JaguarBlue
eaf276221995VolvoBlue
187216d51986AudiBlack
2b91a0531976MercedesMaroon
4ecd97361995AudiWhite
Car Info
<h:form id="form">
    <p:dataTable id="cars" var="car" value="#{dtContextMenuView.cars}" rowKey="#{car.id}"
                 selection="#{dtContextMenuView.selectedCar}" selectionMode="single">
        <f:facet name="header">
            RightClick to View Options
        </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:dataTable> 

    <p:contextMenu for="cars">
        <p:menuitem value="View" update="carDetail" icon="pi pi-search" oncomplete="PF('carDialog').show()"/>
        <p:menuitem value="Delete" update="cars" icon="pi pi-times" action="#{dtContextMenuView.deleteCar}"/>
    </p:contextMenu>
    
    <p:dialog header="Car Info" widgetVar="carDialog" modal="true" showEffect="fade" hideEffect="fade" resizable="false">
        <p:outputPanel id="carDetail" style="text-align:center;">
            <p:panelGrid  columns="2" rendered="#{not empty dtContextMenuView.selectedCar}" columnClasses="label,value">
                <f:facet name="header">
                    <p:graphicImage name="demo/images/car/#{dtContextMenuView.selectedCar.brand}-big.gif"/> 
                </f:facet>
                
                <h:outputText value="Id:" />
                <h:outputText value="#{dtContextMenuView.selectedCar.id}" />

                <h:outputText value="Year" />
                <h:outputText value="#{dtContextMenuView.selectedCar.year}" />

                <h:outputText value="Color:" />
                <h:outputText value="#{dtContextMenuView.selectedCar.color}" style="color:#{dtContextMenuView.selectedCar.color}"/>
            
                <h:outputText value="Price" />
                <h:outputText value="$#{dtContextMenuView.selectedCar.price}" />
            </p:panelGrid>
        </p:outputPanel>
    </p:dialog>
</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.