This is a migrated thread and some comments may be shown as answers.

Kendo dynamic context menu

4 Answers 1426 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Anamika
Top achievements
Rank 1
Anamika asked on 22 Oct 2014, 09:35 AM
Hello,
I have a context menu displayed on right clicking kendo grid like this.
@(Html.Kendo().ContextMenu()
        .Name("menuGrid")
        .Target("#Grid_ObjActivity")
        .Orientation(ContextMenuOrientation.Vertical)
        .Animation(animation =>
        {
            animation.Open(open =>
            {
                open.Fade(FadeDirection.In);
                open.Duration(500);
            });
        })
        .Items(items =>
        {

            items.Add()
               .Text("Herunterladen")
               .ImageUrl(Url.Content("~/Images/Download.png"));
            items.Add()
              .Text("Löschen")
              .ImageUrl(Url.Content("~/Images/Delete.png"));

        })
        .Events(e => e.Select("ContextClick"))

    )

This is ok but i would like to have the items added dynamically depending on type of row clicked on grid. Each row in grid has a different type and right clicking show a different context menu with different action.

How can i achieve this in my razor view.

Thanks

Anamika

4 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 24 Oct 2014, 07:36 AM
Hello Anamika,

It is possible to use the setOptions method to set the dataSource option in the open event in order to show different items for each row. I created an example that demonstrates this scenario.


Regards,
Daniel
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Matt
Top achievements
Rank 1
answered on 25 Mar 2015, 10:08 PM
Hi Daniel,
Any reason that, if I attempt to add a submenu to any of the dynamically created menu items, they won't appear?

See example.  The parent item will only flicker, w/ the child item never appearing.

Thanks.
0
Matt
Top achievements
Rank 1
answered on 25 Mar 2015, 10:09 PM
Hi Daniel,
Any reason that, when attempting to add a sub-menu to the dynamically created menu, it doesn't show?

See example.  The parent menu will flicker when hovered over, but never shows it's children.

Thanks.
0
Daniel
Telerik team
answered on 27 Mar 2015, 09:39 AM
Hello Matt,

Because the open event will be triggered when opening the sub items. You can check what is the item parameter before setting the items in order to avoid the problem e.g.
function onOpen(e) {            
    if ($(e.item).is("li")) {
        return;
    }
    ...


Regards,
Daniel
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
Menu
Asked by
Anamika
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Matt
Top achievements
Rank 1
Share this question
or