Remove item in context menu

Tags: #<Tag:0x00007efc718ea728> #<Tag:0x00007efc718ea520>

Hello, I have looked through this example https://jsfiddle.net/p5w7vy3n/ and I have a question regarding the context menu. In this case, could I change the condition for the “remove_row” option to something like this?

  settings3 = {
    data: getData(),
    rowHeaders: true,
    colHeaders: true,
    licenseKey: 'non-commercial-and-evaluation',
    contextMenu: {
      items: {
      	"make_read_only": {},
        "row_above": {},
        "row_below": {},
        "remove_col": {},
        "remove_row": {
          hidden: function() {
             tableData.forEach(row => {
               if (row.editable && row.hasYear) {
                 return false
               } else {
                 return true
               }
             }
          }
        }
      }
    }
  };

I want the “remove row” option to be displayed only for certain rows that have those 2 properties and it seems to not be working like this.

Thank you!

Hi @vitorialipan

We have a similar example showing how to turn on particular context menu options for chosen rows or columns: https://jsfiddle.net/handsoncode/13045hvn/ Would that solution work for you?

Hello,

It seems that hot.getSelectedRangeLast().to.row was what I was missing in my code, so it was an oversight on my part.

Thank you very much and have a nice day!

Hi @vitorialipan

I’m glad that it worked for you. I will close this topic now.