Our pure JavaScript Scheduler component


Post by Luffy »

Hey guys,
I am working on a customised contextMenu.
I want to disable some menu item based on a condition.

contextMenu - disabled item.png
contextMenu - disabled item.png (6.37 KiB) Viewed 751 times

as an example, in the above image, is there any way to disable the Edit event.
Still want to show it but as a disabled menu item. So user can see that it was disabled.

    eventContextMenu: {
      processItems: ({ items }) => {
        (items.deleteEvent = false),
          (items.unassignEvent = false),
          (items.editEvent = false);
      },
      items: [
        {
          text: 'Edit event',
          icon: 'icon proicon-pencil-16',
          onItem: ({ item }) => console.log(item.text),
        },
        {
          text: 'Find next available resource',
          icon: 'icon proicon-search-16',
          onItem: ({ item }) => console.log(item.text),
        },
        {
          text: 'Show event on map',
          icon: 'icon proicon-map-pin-square-16',
          onItem: ({ item }) => console.log(item.text),
        },
        {
          text: 'Drill to event',
          onItem: ({ eventRecord }) => drillBackTo(eventRecord, 'EVENT'),
        },
        {
          text: 'Drill to customer',
          onItem: ({ eventRecord }) =>
            drillBackTo(eventRecord.data.customerCode, 'CUSTOMER'),
        },
      ],
    },

Is there any property or something which can make the menu item disabled.

Thanks in advance.


Post by pmiklashevich »

Hello,

You can configure any widget including a menu item as disabled. For example:

let scheduler = new Scheduler({
    features : {
        eventContextMenu : {
            processItems : ({ items }) => {
                if (items.editEvent) {
                    items.editEvent.disabled = true;
                }
            }
        }
    },
Снимок экрана 2020-05-26 в 13.07.22.png
Снимок экрана 2020-05-26 в 13.07.22.png (83.23 KiB) Viewed 744 times

We will update docs and code snippets to make it more clear. Thanks for your feedback!

Cheers,
Pavel

Pavlo Miklashevych
Sr. Frontend Developer


Post by Luffy »

Thanks Pavel. It worked. :)


Post Reply