Skip to main content

ASPxScheduler.PopupMenuShowing Event

Occurs before a popup menu is created and allows you to customize the menu.

Namespace: DevExpress.Web.ASPxScheduler

Assembly: DevExpress.Web.ASPxScheduler.v24.2.dll

NuGet Package: DevExpress.Web.Scheduler

#Declaration

public event PopupMenuShowingEventHandler PopupMenuShowing

#Event Data

The PopupMenuShowing event's data class is PopupMenuShowingEventArgs. The following properties provide information specific to this event:

Property Description
Menu Gets the popup menu for which this event was raised.

#Remarks

Handle the PopupMenuShowing event to modify the popup menu every time it is shown. Use the Menu event argument property to access the current popup menu.

#Example 1

The code sample below demonstrates how to customize a popup menu item and change the default action assigned to a menu item.

function DefaultViewMenuHandler(scheduler, s, args) {
    if (args.item.GetItemCount() <= 0) {
        if (args.item.name == "GotoToday") {
            if (window.confirm("Are you realy want to leave this day?")) {
                scheduler.RaiseCallback("GOTODAY|" + args.item.name);
            }
        }
        else
            scheduler.RaiseCallback("MNUVIEW|" + args.item.name);
    }
}
using DevExpress.Web;
using DevExpress.Web.ASPxScheduler;
using DevExpress.XtraScheduler;
    protected void ASPxScheduler1_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e) {
        ASPxSchedulerPopupMenu menu = e.Menu;
        if (menu.MenuId.Equals(SchedulerMenuItemId.DefaultMenu)) {
            menu.ClientSideEvents.ItemClick = String.Format("function(s, e) {{ DefaultViewMenuHandler({0}, s, e); }}", ASPxScheduler1.ClientInstanceName);
            MenuItemCollection menuItems = menu.Items;
            MenuItem defaultItem = menuItems.FindByName("NewAppointment");
            defaultItem.Name = "MyNewAppointment";
            defaultItem.Text = "Instant Appointment";
        }
    }

#Example 2

The following example illustrates how to creates custom popup menu items.

protected void ASPxScheduler1_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e) {
            // An additional item is added into the "Appointment" menu to switch the "Completed" state of a current appointment
            // A currently selected appointment is updated on a separate callback request which is invoked in the client-side MenuItemClicked event handler
    if(e.Menu.MenuId == DevExpress.XtraScheduler.SchedulerMenuItemId.AppointmentMenu) {
        e.Menu.ClientSideEvents.PopUp = "OnClientPopupMenuShowing";
        DevExpress.Web.MenuItem newItem = new DevExpress.Web.MenuItem();
        newItem.Name = "ChangeCompletedStatus";
        newItem.Text = "Mark as Completed";
         e.Menu.Items.Add(newItem);
    }

            // Additional items are added into the "Default (View)" metnu to switch the "Group Type" parameter
            // A current groupping type is changed by executing the client-side SetGroupType method in the MenuItemClicked event handler
    if(e.Menu.MenuId == DevExpress.XtraScheduler.SchedulerMenuItemId.DefaultMenu) {
        DevExpress.Web.MenuItem newSubItem = new DevExpress.Web.MenuItem();
        newSubItem.Name = "ChangeGroupType";
        newSubItem.Text = "Change Group Type";

        DevExpress.Web.MenuItem subMenuItemDate = new DevExpress.Web.MenuItem();
        subMenuItemDate.Name = "GroupByDate";
        subMenuItemDate.GroupName = "ChangeGroupType";
        subMenuItemDate.Text = "Group By Date";
        subMenuItemDate.Checked = ASPxScheduler1.GroupType == SchedulerGroupType.Date;
        newSubItem.Items.Add(subMenuItemDate);

        DevExpress.Web.MenuItem subMenuItemResource = new DevExpress.Web.MenuItem();
        subMenuItemResource.Name = "GroupByResource";
        subMenuItemResource.GroupName = "ChangeGroupType";
        subMenuItemResource.Text = "Group By Resource";
        subMenuItemResource.Checked = ASPxScheduler1.GroupType == SchedulerGroupType.Resource;
        newSubItem.Items.Add(subMenuItemResource);

        DevExpress.Web.MenuItem subMenuItemNone = new DevExpress.Web.MenuItem();
        subMenuItemNone.Name = "GroupByNone";
        subMenuItemNone.GroupName = "ChangeGroupType";
        subMenuItemNone.Text = "Group By None";
        subMenuItemNone.Checked = ASPxScheduler1.GroupType == SchedulerGroupType.None;
        newSubItem.Items.Add(subMenuItemNone);

        e.Menu.Items.Add(newSubItem);
    }
}
See Also