Different context menus for table columns

Hi,

I’m would like to add a context menu to a table. Some columns should have a context menu, some not. I’m trying to use the Action.Handler-mechanism for this. I have two problems with this feature:

  1. The getActions method allows me to return different actions per item/per row, but not per column. So all columns will get the same actions.
  2. From the parameters of the handleAction method I can not tell, in which column the right click occured. Again, I get the row (parameter target) but not the column, so I can not identify the exact cell for which the user triggered the context menu action.

Am I missing something obvious? Is the Action.Handler not intended to be used in this way with a table?

I did not yet try it with the
ContextMenu add-on
because I thought that if a context menu on tables is already supported in Vaadin core, this functionality for handling each column separately should somehow be possible without an add-on.

Kind regards

Bastian Krol

I think the action handler is created only once at table initialization and reused afterwards.

I think I have read in the forum somewhere that calling table.requestRepaint() from the ValueChangeListener would force the action handler to be recreated at every selection change event, but I haven’t tried.

Using the context menu add-on should makes things easier and less hackish for you.