Skip to main content
A newer version of this page is available. .

ASPxScheduler.PopupMenuShowing Event

Occurs before a popup menu is created and allows menu customization.

Namespace: DevExpress.Web.ASPxScheduler

Assembly: DevExpress.Web.ASPxScheduler.v19.1.dll

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 or sets the popup menu for which this event was raised.

Remarks

Handle the PopupMenuShowing event to modify the popup menu every time it is shown. The current popup menu can be accessed via the PopupMenuShowingEventArgs.Menu property.

The types of all popup menu items are listed in the SchedulerMenuItemId enumeration.

The page called DefaultItemWithCustomAction illustrates how to change the default action assigned to a menu item. It uses two different techniques to modify the existing menu.

One technique involves a JavaScript function defined in the page markup that replaces the default GoTo command with a custom handler. The ASPxScheduler.PopupMenuShowing event is handled to specify a JavaScript handler.

Another technique implements a CustomMenuViewCallbackCommand command that is used to perform a callback. The ASPxScheduler.BeforeExecuteCallbackCommand event should be handled to process the command. The ASPxScheduler.PopupMenuShowing event is handled to rename a menu item so it can be properly recognized by a custom callback command.

The code in the event handler changes the MenuItem.Name of the default New Appointment menu item to “MyNewAppointment” on the client side. The MenuItem.Text string that is displayed is changed to “Instant Appointment”. So, the popup menu displays the “Instant Appointment” text instead of the default text for the “New Appointment” command. When the user selects this item, a “MyNewAppointment” string is passed as a menu identifier to a callback command.

<script type="text/javascript">
    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);
        }
    }
</script>
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

The following example illustrates how to use the ASPxScheduler.PopupMenuShowing event.

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