Board index JavaServer Faces General Overlay menu/panel on datatable row

Overlay menu/panel on datatable row

Components, Ajax Framework, Utilities and More.


Posts: 387
Hi ,

Is it possible to get the overlay menu/panel on the datatable row which gets triggered on row selection or single selection ? I am right now using context menu which opens on right click but i have a requirement where the menu should come up on simple left click .


Thanks

Using PF3.3 snapshot , Mojarra 2.13 , WAS 7 ,jre1.6


Posts: 32
I would also like to know more about this. I have successfully gotten it to sort of work by assigning the overlayPanel, outside of the dataTable, to a commandLink that's also outside of the dataTable, then using jQuery trigger from commandLinks within my table rows to simulate mousedown on that outside commandLink, which itself is assigned to the overlayPanel. Problem is, even using the jQuery Event object to set positioning, the overlayPanel just positions itself in the upper lefthand corner of the viewport.

Anyone else ever successfully gotten this to work (or regular p:menus, as an option)? Thanks.

Oleg User avatar
Expert Member

Posts: 3702
Location: Russia, Siberia => Germany, Black Forest
Context menu means menu on right click. This is the nature of context menu. But in general, yes, I said this already many times - any trigger event would be nice. Have you tried this with datatable?

<p:menu overlay="true" trigger="..." my="left top" at="left bottom">
    ...
</p:menu>

or

<p:tieredMenu overlay="true" trigger="..." my="left top" at="left bottom">
    ...
</p:tieredMenu>

By the way, p:menu and p:tieredMenu are almost the same, only behavior of submenus is different.
PrimeFaces 4.x, 5.x, Mojarra 2.2.x, JBoss WildFly, WebSphere, Windows 8.1, IntelliJ IDEA
PrimeFaces Cookbook: http://ova2.github.com/primefaces-cookbook/ PrimeFaces Extensions on GitHub: http://primefaces-extensions.github.com/


Posts: 32
My thought with contextMenu was just to trigger right-click using hover on a commandComponent, which correctly controls rowSelect (right-click would still also work, but this would be a second way to activate - no one expects to use context menus on the web, afaik). However, all my attempts at triggering the event are failing to call up the context menu. For regular menus or overlays that expect to have a relation to a trigger target (for at and my positioning), the problem is trying to make an association with a component that lives inside a table row, and therefore has a dynamically generated id containing a rowIndexVar. Doesn't seem to work to use an Id containing a rowIndexVar, for example, in a "for" attribute value. That will work on a widgetVar, but these things are designed to be bound declaratively, using the trigger's component ID.

I even tried triggering menus/overlays using an intermediary trigger/link/target outside the table and passing in coords. Like I said, that "works" (sorta), but the positioning fails and so does (so far) my attempts to trigger the secondary target with other row component events, like mouseenter/hover.


Posts: 32
Thought a short code example might help:

<p:dataTable rowIndexVar="rowIndexVar">
<p:column>
<p:commandLink id="myTrigger">
<f:param name="rowIndexVar" value="#{rowIndexVar}" />
</p:commandLink>
</p:column>
</p:dataTable>
<p:menu trigger="myDatatable:#{rowIndexVar}:myTrigger" />


or similar (trigger value with or without a leading colon), doesn't work (errors out), even if I pass the variable rowIndexVar on rowSelect. I think this didn't cause page error:

<p:menu for="myDatatable:myTrigger" />


but it also didn't do anything on command-component-based rowSelect.

The actual Id of the command component resolves to

id="myForm:myDatatable:{n}:myTrigger"


where {n} is the rowIndexVar. Trying to reference that complete component path also doesn't work, with or without a leading colon.

Hope this isn't more confusing than helpful to anyone with a possible answer.


Return to General