Possible to attach context menu to grid rows but not to contained links?

5 posts, 0 answers
  1. Uwe
    Uwe avatar
    10 posts
    Member since:
    Mar 2008

    Posted 19 Oct 2015 Link to this post

    What I'm successfully doing is to attach a ContextMenu to a Grid:

    @(Html.Kendo().ContextMenu()
      .Name(@"menu")
      .Target(@"#grid")
      .Filter(@"tbody tr td")
      .Orientation(ContextMenuOrientation.Vertical)
      .Animation(false)
      .Events(evt => evt.Select(@"contextMenuItemSelect").Open(@"contextMenuOpen"))
      .Items(
          items =>
          {
          items.Add().Text(​"Rename");
          items.Add().Text("Delete");
          })
    )

    This works just as expected.

    Now what I'm trying to do is to allow my Kendo context menu when clicking on a cell but show the browser's built-in menu when clicking on a link inside a cell. (See attached image)

    I've tried various filters like .Filter(@"tbody tr td :not(a)") but this only results in a completely no-appearing context menu.

    My question:

    Is it possible to somehow achieve what I want?

  2. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2156 posts

    Posted 22 Oct 2015 Link to this post

    Hello Uwe,

    There is no viable solution that we could suggest for the current scenario. A possible workaround would be to add a CSS class to the cell containing the link and exclude it in the Context Menu filter configuration via jQuery's not selector. This way the context menu will not be shown for the whole cell, containing the link.
    E.g.

    .Target("#grid")
    .Filter("tbody tr td:not(.linkCell)")

    Regards,
    Dimiter Madjarov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Uwe
    Uwe avatar
    10 posts
    Member since:
    Mar 2008

    Posted 22 Oct 2015 in reply to Dimiter Madjarov Link to this post

    Thanks for your help, Dimiter.
  5. Arpit
    Arpit avatar
    1 posts
    Member since:
    Jan 2016

    Posted 06 Jan Link to this post

    i have a grid and i want to attach context menu to the last cell of a row on left click of mouse.

    How to achieve this?

  6. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2156 posts

    Posted 07 Jan Link to this post

    Hello Arpit,

    By design the context menu is only opened on right click. In order to implement the current scenario, you could manually force the context menu to open by using it's open method. The open method accepts as parameters the coordinates where it should be opened.

    Regards,
    Dimiter Madjarov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready