Our pure JavaScript Scheduler component


Post by pavithrapronto »

Hi,

In the context menu I have an element called "Edit event"
When I click this, I want to trigger the editEvent dialog

Please refer the image

Attachments
triggerEditEvent.png
triggerEditEvent.png (34.37 KiB) Viewed 1365 times

Post by mats »


Post by pavithrapronto »

Im inside the config code. In this code I have a context menu (NOT the eventContextMenu), which has a menu item called "Edit Event". When I click on this, I need to open the event editor.

This is my Code.

const scheduler = {
  id: 'unallocated-work-grid',
  startDate: new Date(2019, 8, 1, 6),
  endDate: new Date(2019, 11, 1, 6),
  viewPreset: 'weekAndDay',
  barMargin: 5,
  rowHeight: 40,
  emptyText: 'Fetching records...',
  showRemoveRowInContextMenu: false,
  createEventOnDblClick: false, 
  features: {
    contextMenu: {
      cellItems: [
        {
          text: 'Edit event',
          onItem: ({ item }) => console.log(item.text),
        },
        {
          text: 'Custom Menu item',
          onItem: ({ item }) => console.log(item.text),
        },
      ],
    },
   },
  };

Basically, what I need is to get the eventEdit item which is by default in the eventContextMenu to the contextmenu

Thank you!


Post by pmiklashevich »

Hello, you can get resource in the parameters. And then you can get its events. Just need to decide what event to edit:

const scheduler = new Scheduler({
    showRemoveRowInContextMenu : false,
    createEventOnDblClick      : false,
    features                   : {
        contextMenu : {
            cellItems : [
                {
                    text   : 'Edit event',
                    onItem : ({ item, record }) => {
                        console.log(item.text, record.events);

                    // choose somehow what event you want to edit, since there can be any or none
                    if (record.events.length) {
                        scheduler.editEvent(record.events[0]);
                    }
                    else {
                        alert('No events to edit!');
                    }
                }
            }
        ]
    }
},

Cheers!

Pavlo Miklashevych
Sr. Frontend Developer


Post by pavithrapronto »

I tried it. but it shows red underline on "eventEdit"

Please refer the attached image

Attachments
eventEditError.png
eventEditError.png (36.31 KiB) Viewed 1354 times

Post by mats »

Set a breakpoint there, look a bit - do you have a variable called scheduler? If not, make sure you do.


Post Reply