have you ever been annoyed when adding a layout to your Table breaks the selection of rows? Well, that’s not a problem any more since I just released the TableClickForwarder 0.0.1 add-on!
In all it’s simplicity, it is an extension which just adds mouse down/up handlers for any component, and dispatches these events to the parent TD within your Table.
It works fine. Currently i try to do is: Is the element a button, the event should not pass.
So i tried onMouseUp
if (el == null ||el instanceof ButtonElement)
{ return; }
The element is always [object HTMLTableCellElement]
, altough i pressed a label or button
EDIT: More Infos:
I have a table cell with a HorizontalLayout. The HorizontalLayout contains a Label and a Button. How can i different a click on the button or label with the element el? If the button is clicked, i don’t want pass the event (don’t select the row)
Oh I see. I think the problem is that the extension will pass on any mouse down/up events from the contained components. no matter which components they are. I should add an ‘ignore’ for buttons etc.
thanks for that addon, this is quite useful for tables with some custom content. I’m also wondering how you decide which kind of Element in the layout is clicked, maybe useful not only for buttons but also for textfields, checkboxes, etc.
yeah, seems it’s going to be a bit problematic to decide when to dispatch the event and when not. Currently there is no ‘filtering’ so probably any click events within any components will go through, which is not that nice if you have some buttons and fields in the cell.
Obviously the issue is trivial if you only have a button/field in the cell - just don’t add the extension for that component.
I’ll see what I could do to make the forwarding more reasonable, although I’d hate to add explicit checks for all kinds of fields etc. into the code…
The check has to be done within the client-side class of the extension - basically you just need to check the type of the event source.
I released a new version (0.0.2) of the add-on. It will now ignore all events which originate from anything extending the Focusable interface on the client side. This includes e.g. buttons, textfields, checkboxes and should include all vaadin fields.
Please try it out and let me know if the solution is good enough, thanks.
and thanks for noting this. The extension does not currently handle double click events, only normal mouse clicks (left/right button and possible modified keys). I added the support for double click events and will publish a new version once I’ve tested it.
This plugin looks like the solution to problems I am having with row selection and context menus in tables with layouts in cells. I tried it on Vaadin 7.3.6 but it doesn’t seem to be working. I added traces in a local copy of the plugin and verified the mouse events are being forwarded to the table in the DOM on the client side, but the table is not receiving those events on the server side. A colleague also tryed running the demo on Vaadin 7.3.6 and could not get that to work with row selection either. Is this a known issue on 7.3.6?
not select the whole row, just set focus to the table row. I think, the table component not catches the event (mouse down / focus etc) and the not know about the selection.
Can somebody fix the issue?