Customize contextMenu according to current selection?

Tags: #<Tag:0x00007f8b1d634598>

Hi there,

I’d like to control the accessibility and the behavior of a custom context menu item, ideally as follows:

  • if the current selection spreads over more than a single row, disable that menu item
  • else enable or disable it depending on the row concerned with the selection
  • when enabled, adjust its behavior also depending on the row concerned.
    The menu item’s purpose would for example be to insert a row with some predefined cell contents above the selection.

I tried to play a bit with the “beforeContextMenuSetItems”… to no avail, so far.
Thanks in advance for any hint!

Hi @brunos

I think that you’ll be able to add every one of this options via custom context menu item. Here’s an example when I block the option visibility to certain rows (if you add an IF you can block it depending on a row index) http://jsfiddle.net/handsoncode/59ybb588/

Hi Aleksandra,

Thank you! Context menus don’t show up when running the fiddle on my desktop, I don’t know why, but in any case your example is very helpful, I didn’t know about the “hidden” property in this context (no pun intended).

I’m trying to build up simple “use-cases” in order to get familiar with your nice product (wrapped over Vue) and I’m still at the bottom of the learning curve, so please forgive that stupid question of mine: how do you get access to the hot instance in a vue environment?

That’s actually not a stupid question. A lot of our users asked the same one.

Here’s a topic that I recommend https://github.com/handsontable/vue-handsontable-official/issues/30 it is about a core method called render (which is quite useful in made cases). It looks like you need to add a ref to the element and then use it like

ref
<HotTable :root="root" :settings="hotSettings" ref="myTable"></HotTable>

call
this.$refs.myTable.table