Our powerful JS Calendar component


Post by tdset »

Hi,

we're using the calendar with day/week/month/timeline (scheduler) mode and would like to conditionally disable the delete function on some events.

Now it's very easy to delete events, and some of these events are important.

Ideally we should either disable the delete function when events are rendered or react to the request of trying to delete an event.

I've conditionally hidden the delete context menu using eventMenu processItems.
But there are many other ways in how an entry can be deleted:

  • via the tooltip delete button
  • via the keyboard

Can you give me some hints on how we can accomplish this?


Post by mats »

You will need to hide the various UI elements using our configurations, and for the keyboard option - you can listen to https://bryntum.com/docs/calendar/api/Calendar/view/Calendar#event-beforeEventDelete and return false to veto the deletion.


Post by tdset »

thank you Mats. beforeEventDelete sounds good.

I'm trying to figure it out how to get the event the tooltip is shown on so I can decide if the delete button is shown.
Here's what I have now which obviously doesn't work:

features: {
        eventTooltip : {
            showOn : 'click',
            renderer: data => `
                custom html to show in the tooltip
            `,
            tooltip : {
                tools : {
                    delete: this.eventRecord.status == 'published' ? false : true
                },
            },
        },

thank you for your help


Post by tasnim »

To achieve that you can use the beforeShow event.
Here is an example:

const calendar = new Calendar({
    ...
    features : {
        eventTooltip : {
            listeners: {
                beforeShow({ source }) {
                    source.tools.delete = false;
                }
            }
        }
    }
});

Best regards,
Tasnim


Post by tdset »

Thank you, the listener works great. Much appreciated!


Post Reply