ContextMenu in RadzenScheduler

Is there a way to use context menu for slot and appointment in RadzenScheduler?

Hi @stoiccoder,

At the moment you can add a context menu for appointments. Here is an example based on our online demo:

    <RadzenScheduler @ref=@scheduler style="height: 768px;" TItem="Appointment" Data=@appointments StartProperty="Start" EndProperty="End"
        TextProperty="Text" SelectedIndex="2"
        SlotSelect=@OnSlotSelect AppointmentSelect=@OnAppointmentSelect AppointmentRender=@OnAppointmentRender>
        <ChildContent>
            <RadzenDayView />
            <RadzenWeekView />
            <RadzenMonthView />
        </ChildContent>
        <Template>
            <div @oncontextmenu=@(args => ShowMenu(args, context)) 
              @oncontextmenu:preventDefault="true">
                @context.Text
            </div>
        </Template>
    </RadzenScheduler>
@code {
    void ShowMenu(MouseEventArgs args, Appointment data)
    {
        ContextMenuService.Open(args, new List<ContextMenuItem> { 
          new ContextMenuItem { Text = "Edit", Value = data } }, 
        OnMenuItemClick);
    }

    void OnMenuItemClick(MenuItemEventArgs item)
    {
        ContextMenuService.Close();
        if (item.Text == "Edit")
        {
            DialogService.Open<EditAppointmentPage>("Edit Appointment", new Dictionary<string, object> { { "Appointment", item.Value } }); 
        }
    }
}
1 Like