Author Topic: Context menu  (Read 1943 times)

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 341
    • View Profile
Context menu
« on: June 19, 2019, 03:56:55 pm »
Would it be possible to disable context menu option based on cell value?
Option should be disabled and no action performed when clicked.

Using:

Code: [Select]
function bodyItems(evt, ui){
        return [
         
               {
                    name: "test",
                    disabled: false,
                    action: function(evt, ui){
                    // do something
                    }
                }
                ]}

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Context menu
« Reply #1 on: June 19, 2019, 06:58:30 pm »
Yes, cell value can be found from ui.rowData[ui.dataIndx]

Code: [Select]
var val = ui.rowData[ui.dataIndx]

and context menu item can be disabled based on cell value

Code: [Select]
function bodyItems(evt, ui){
        var val = ui.rowData[ui.dataIndx], disabled = ( 1 < val < 10);
        return [
         
               {
                    name: "test",
                    disabled: disabled,
                    action: disabled? null: function(evt, ui){
                    // do something
                    }
                }
                ]}