ContextMenu with Scheduler

3 posts, 0 answers
  1. Michael
    Michael avatar
    43 posts
    Member since:
    Dec 2010

    Posted 01 Dec 2014 Link to this post

    I am trying to integrate the kendo ContextMenu with the Scheduler.  I found an example, but would rather use your context menu instead (,js,output).  According to your docs, if I use a filter, then should be the element found via the filter: "The current target of the ContextMenu - either the init target or the current element chosen through filter, if specified."  For some reason though, is always the body element.  I don't know if that's because of the way I am appending the context menu to the body, or if it's something else.  Below is the Typescript method I have that creates and sets up the context menu for my scheduler.  It DOES show the context menu when I right-click a scheduler event, but the alert I threw in there always shows undefined, since is not the actual element with the "k-event" css class (the block with an event in the scheduler).  Any ideas?

    private setupContextMenu() {
                this._$contextMenu = $("<ul id='" + this._$scheduler.attr("id") + "-context-menu'></ul>").appendTo($("body"));
                this._contextMenu = new kendo.ui.ContextMenu(this._$contextMenu[0], {
                    filter: '.k-event',
                    dataSource: [{text: "Edit", spriteCssClass: "fa fa-edit" }, { text: "Delete", spriteCssClass: "fa fa-trash" }]
                this._contextMenu.bind("select", (e) => {
                    var dataSource = this._scheduler.dataSource;
                    var uid = $("data-uid");

                    if (e.item.textContent === "Edit") {
                        var dataItem = <>dataSource.getByUid(uid);
                    } else if (e.item.textContent === "Delete") {
                        var dataItem = <>dataSource.getByUid(uid);
  2. Georgi Krustev
    Georgi Krustev avatar
    3687 posts

    Posted 03 Dec 2014 Link to this post

    Hello Michael,

    That is a strange behavior. In general, the element should be filtered based on the filter option. The same approach is used in this Dojo demo that demonstrates ContextMenu usage in Scheduler widget.

    In order to assist you further, I will need a repro demo. Thus I will be able to narrow the problem down and advice you further.

    Georgi Krustev
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Michael
    Michael avatar
    43 posts
    Member since:
    Dec 2010

    Posted 03 Dec 2014 in reply to Georgi Krustev Link to this post

    Hi Georgi,
    Just fyi, in your demo, line 143 needs to point to the contextMenuSelect function.  I will review my implementation again when I get a chance.  If it's working for both of those demos, then maybe I just have something wrong.  If I can't figure it out, I can spend the time to make a stand-alone demo project.  Thanks!


Back to Top