)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Essential JS2

Syncfusion jQuery based widgets are no longer in active development. Switch to our pure JavaScript based next generation Essential JS 2 library.

Syncfusion Feedback

How to add icons/images beside the Scheduler context-menu items?

Platform: jQuery |
Control: ejSchedule |
Published Date: July 14, 2016 |
Last Revised Date: May 28, 2019

The following steps helps you to add image/icon to the Scheduler context-menu items.

  1. Create a Schedule sample with context-menu option by referring the following links.

Sample link: http://js.syncfusion.com/demos/web/#!/azure/schedule/contextmenu

UG link: http://help.syncfusion.com/js/schedule/context-menu

 

  1. Create the necessary style classes to be applied for the context-menu items.
    <style type="text/css">
            [class*="img-"] {
                height: 14px;
                left: 2px;
                top: 4px;
                width: 15px; 
            }
     
            .img-1 {
                background-image: url("14.1.0.41/themes/web/content/images/schedule/print.png");
                background-position: -25px 0;
            }
     
            .img-2 {
                background-image: url("14.1.0.41/themes/web/content/images/schedule/bell.png");
                background-position: -25px 0;
            }
        </style>
    

 

  1. Add an additional field named sprite which holds the class name of the background image(s) and its properties within the contextMenuSettings property as shown below.
    contextMenuSettings: {
                        enable: true,
                        menuItems: {
                            appointment: [
                                { id: "open", text: "Open Appointment" },
                                { id: "delete", text: "Delete Appointment" },
                                { id: "customMenu3", text: "Menu Item 3" },
                                { id: "customMenu4", text: "Menu Item 4" },
                                { id: "categorize", text: "Categorize" }
                            ],
                            cells: [
                                { id: "new", text: "New Appointment", sprite: "img-1" },
                                { id: "recurrence", text: "New Recurring Appointment" },
                                { id: "today", text: "Today" },
                                 { id: "gotodate", text: "Go to date", sprite: "img-2" },
                                { id: "settings", text: "Settings" },
                                { id: "view", text: "View", parentId: "settings" },
                                { id: "timemode", text: "TimeMode", parentId: "settings" },
                                { id: "view_Day", text: "Day", parentId: "view" },
                                { id: "view_Week", text: "Week", parentId: "view" },
                                { id: "view_Workweek", text: "Workweek", parentId: "view" },
                                { id: "view_Month", text: "Month", parentId: "view" },
                                { id: "timemode_Hour12", text: "12 Hours", parentId: "timemode" },
                                { id: "timemode_Hour24", text: "24 Hours", parentId: "timemode" },
                                { id: "businesshours", text: "Business Hours", parentId: "settings" },
                                { id: "customMenu1", text: "Menu Item 1" },
                                { id: "customMenu2", text: "Menu Item 2" }
                            ]
                        }
                    }
    

 

  1.  Before the context menu gets opened, beforeContextMenuOpen event will be raised. In that event, define the default field name of menu control, spriteCssClass additionally (default field of ejMenucontrol) which holds the sprite field name as shown below for the Scheduler context-menu items.

 

$(function () {
            var dManager = ej.DataManager(window.Default).executeLocal(ej.Query().take(10));
            $("#Schedule1").ejSchedule({
                width: "100%",
                height: "525px",
                currentDate: new Date(2014, 4, 5),
                contextMenuSettings: {
                    enable: true,
                    menuItems: {
                        appointment: [
                            { id: "open", text: "Open Appointment" },
                            { id: "delete", text: "Delete Appointment" },
                            { id: "customMenu3", text: "Menu Item 3" },
                            { id: "customMenu4", text: "Menu Item 4" },
                            { id: "categorize", text: "Categorize" }
                        ],
                        cells: [
                            { id: "new", text: "New Appointment", sprite: "img-1" },
                            { id: "recurrence", text: "New Recurring Appointment" },
                            { id: "today", text: "Today" },
                             { id: "gotodate", text: "Go to date", sprite: "img-2" },
                            { id: "settings", text: "Settings" },
                            { id: "view", text: "View", parentId: "settings" },
                            { id: "timemode", text: "TimeMode", parentId: "settings" },
                            { id: "view_Day", text: "Day", parentId: "view" },
                            { id: "view_Week", text: "Week", parentId: "view" },
                            { id: "view_Workweek", text: "Workweek", parentId: "view" },
                            { id: "view_Month", text: "Month", parentId: "view" },
                            { id: "timemode_Hour12", text: "12 Hours", parentId: "timemode" },
                            { id: "timemode_Hour24", text: "24 Hours", parentId: "timemode" },
                            { id: "businesshours", text: "Business Hours", parentId: "settings" },
                            { id: "customMenu1", text: "Menu Item 1" },
                            { id: "customMenu2", text: "Menu Item 2" }
                        ]
                    }
                },
 
                appointmentSettings: {
                    dataSource: dManager,
                    id: "Id",
                    subject: "Subject",
                    startTime: "StartTime",
                    endTime: "EndTime",
                    description: "Description",
                    allDay: "AllDay",
                    recurrence: "Recurrence",
                    recurrenceRule: "RecurrenceRule",
                },
                beforeContextMenuOpen: "OnBeforeOpen",
            });
 
        });
        function OnBeforeOpen(args) {
            var obj = $("#Schedule1").data("ejSchedule");
            obj._contextMenu.ejMenu({
                fields: { id: "id", text: "text", parentId: "parentId", spriteCssClass: "sprite" },
            });
        }

 

  1. Run the sample and right click the cell. Image/Icon will get added to the context-menu items as depicted in the below image,

 

Image/Icon added for context-menu items

 

Figure 1: Image/Icon added for context-menu items.

 

Sample link: http://jsplayground.syncfusion.com/tlo3u2ev

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon