禁用顶级菜单项的 radmenu 单击事件
在我的代码中,
MenuList = new Telerik.Web.UI.RadMenuItem();
MenuChild1 = new Telerik.Web.UI.RadMenuItem();
MenuList.Text = "Orders";
MenuList.Value = "Orders";
RadMenu_Control.Items.Add(MenuList);
if (genRights.Find(delegate(UserRights u) { return u.RIGHT_NAME == "Group Master"; }) != null`enter code here`)
{
CategoryList = new Telerik.Web.UI.RadMenuItem();
CategoryList.Text = "Purchase Order";
CategoryList.Value = "order";
MenuList.Items.Add(CategoryList);
//MenuChild1 = new Telerik.Web.UI.RadMenuItem();
//MenuChild1.Text = "PURCHASE ORDER";
//MenuChild1.Value = "order";
//MenuList.Items.Add(MenuChild1);
}
else
{
}
现在我想禁用单击“订单”而不是“采购商订单”,因为它是子项目。
in my code,
MenuList = new Telerik.Web.UI.RadMenuItem();
MenuChild1 = new Telerik.Web.UI.RadMenuItem();
MenuList.Text = "Orders";
MenuList.Value = "Orders";
RadMenu_Control.Items.Add(MenuList);
if (genRights.Find(delegate(UserRights u) { return u.RIGHT_NAME == "Group Master"; }) != null`enter code here`)
{
CategoryList = new Telerik.Web.UI.RadMenuItem();
CategoryList.Text = "Purchase Order";
CategoryList.Value = "order";
MenuList.Items.Add(CategoryList);
//MenuChild1 = new Telerik.Web.UI.RadMenuItem();
//MenuChild1.Text = "PURCHASE ORDER";
//MenuChild1.Value = "order";
//MenuList.Items.Add(MenuChild1);
}
else
{
}
now in this i want to disable click on "Orders" not on "Purchaser order" because it is child item.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
首先,您需要将事件“OnClientItemClicking”添加到您的 RadMenu。像这样:
这是DisableRootClick javascript 函数的主体:
就在这里:)
First you need to add the event "OnClientItemClicking" to to your RadMenu. Like this:
And here is the body of the DisableRootClick javascript function:
And here you go :)
有一个更简单的解决方案:
在服务器端:
当然,您可以在控件中以声明的方式执行此操作
There is a simpler solution:
On the server side:
And, of course you can do it in a declarative manner in the control using
这并不能解决您的问题,但我正在按照文档中此示例的思路实现一些内容: RadMenu 客户端事件文档 它可能会有所帮助。我需要禁用随机子项目和顶级项目。
如果未指定,navigateUrl 将始终是一个假锚点“#”。问题是它也对我想在服务器上处理的点击事件执行此操作,而且我的 rad 菜单混合了绑定到嵌套站点地图和通过后面的代码动态添加菜单项,所以现在我决定测试文本菜单项执行以下操作:
我确信有一个更优雅的解决方案,我至少可以将字符串移动到资源文件并引用它们,但这目前有效......
This doesn't solve your problem but I'm implementing something along the lines of this example from the documentation: RadMenu Client Side Events Documentation and it may help. I need to disable random child and top items.
The navigateUrl will always be a fake anchor "#" if it's not specified. The problem is it also does this for click events that I want to handle on the server, plus my rad menu does a mixture of binding to nested sitemaps and dynamically adding menu items via the code behind so for now I decided to test for the text of the menu item doing the following:
I'm sure there's a more elegant solution, I could at least move the strings to a resource file and reference those, but this works for now...