简体   繁体   English

Kendo菜单一次选择多个项目,ASP.NET MVC

[英]Kendo menu selects multiple items at a time, ASP.NET MVC

I have Kendo menu with actions: 我有动作的剑道菜单:

@(Html.Kendo().Menu().Name("menu")
.Items(it => {                                       
       it.Add().Text("Item1").Items(subit => {
                subit.Add().Text("subitem1).Action("Contracts", "Home");
                subit.Add().Text("subitem2").Action("Contracts", "Home",
                                                       new { flag = true });
 });
 })
)

My problem is that whenever I select subitem1 or subitem2 the items get both selected (class .k-state-selected added to both items). 我的问题是,每当我选择subitem1subitem2这些项目都会同时被选中(将subitem2 .k-state-selected添加到两个项目中)。 I guess that it happens because I have the same controller actions. 我猜想是因为我有相同的控制器动作。 I wouldn't like to create separate action for subitem2 . 我不想为subitem2创建单独的操作。 Is there any workaround? 有什么解决方法吗?

Thanks a lot! 非常感谢!

I am not not if this works because i do not have the kendo library and i cant seem to test it properly at http://dojo.telerik.com/ but basically 我不是不是这样的话,因为我没有kendo库,而且我似乎无法在http://dojo.telerik.com/上正确测试它

Fires before a sub menu gets opened. 在打开子菜单之前触发。

$("#menu").kendoMenu({
     open: function(e) {
           if (location.search != "") {
               $('#menu #item a:first').removeClass('.k-state-selected');
        }
     }
 }); 

It then looks to see if the url has properties, as per the location.search and if it does then it removes the kendo class from the menu first menu item, which is not the one passing anything. 然后,它根据location.search查看该url是否具有属性,如果包含,则从菜单的第一个菜单项中删除kendo类,该菜单项没有传递任何内容。

I am not sure how kendo builds its items, but you might also want to check out if on activate would work better 我不确定kendo如何构建其项目,但您可能还想查看一下activate能否更好地工作

Fires when a sub menu gets opened and its animation finished. 子菜单打开且动画结束时触发。

$("#menu").kendoMenu({
     activate: function(e) {
         // handle event
     }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM