Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

p:dataTable: Trigger rowSelect event when click embedded content (image)

In the example below the rowSelect-event will be triggered if I click a row, but not if clicking the image in the row.

I understand why this happening, but i'm wondering if there is some elegant way to include the subcomponents also (possibly nested subcomponents also)?

<h:form id="form">
    <p:growl id="growl" showDetail="true" />
    <p:dataTable id="cars" var="car" value="#{tableBean.cars}" rows="5"
        selectionMode="single">
        <p:ajax event="rowSelect" listener="#{tableBean.onRowSelect}"
            update=":form" />
        <p:column headerText="Model">
            <p:graphicImage value="myImage.png"
                style="width: 40px; height: 40px;" />
        </p:column>
    </p:dataTable>
</h:form>
like image 911
Aksel Willgert Avatar asked Apr 14 '26 01:04

Aksel Willgert


1 Answers

You can try to add an onclick event on the image:

<p:dataTable rowIndexVar="rowIndex" widgetVar="scrollist"...

... onclick="scrollist.unselectAllRows(); scrollist.selectRow(#{rowIndex})"
like image 55
Samuel Avatar answered Apr 16 '26 23:04

Samuel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!