English 中文(简体)
单层菜单项目可分辨率
原标题:disable radmenu click event for top level menu items
  • 时间:2012-01-12 09:00:45
  •  标签:
  • 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
    {

    }

now in this i want to disable click on "Orders" not on "Purchaser order" because it is child item.

最佳回答

首先,请将“电离射线”的活动添加到你的雷达Menu。 与此类似:

<telerik:RadMenu ID="RadMenu1" runat="server" OnClientItemClicking="DisableRootClick">

这里是可操作的RootClick javascript功能:

function DisableRootClick (sender, args) {
    if (args.get_item().get_items().get_count() != 0 && args.get_item().get_level() == 0) {
            args.get_item().set_selected(false);
            args.get_item().set_focused(false);

            args.set_cancel(true); // Cancel the event
    } 

}

这里请:

问题回答

解决办法更为简单:

在服务器方面:

RadMenuItem.PostBack = False

当然,你在使用控制时能够以声明的方式这样做。

<telerik:RadMenu runat="server" ID="RadMenu1">
    <Items>
        <telerik:RadMenuItem runat="server" Text="RootMenu" PostBack="False" />
    </Items>
</telerik:RadMenu>

这一点没有解决你的问题,但我说,从文件http://www.telerik.com/help/aspnet-ajax/menu-client-side-events.html“rel=“nofollow”)中,执行一些内容。 RadMenu 客户附带活动文件,可提供帮助。 我需要听途说的随机儿童和顶点物品。

如果不具体指明, n将永远是一个摇篮的“#”。 问题在于,如果点击我想要在服务器上处理的事件,再加上我rad的菜单,就是一种具有约束力的组合,通过后面的代码自动添加菜单,现在我决定测试菜单,做以下工作:

<script type="text/javascript">

    function mainRadMenu_OnClientItemClicking( sender, eventArgs ) {

        var item = eventArgs.get_item();

        var itemText = item.get_text();

        var textOfMenuItemsToNotBeClicked = [ Tools ,  Links ,  No Links ,  Services ,  Summary Reports ,  <%= GetOrganizationsAcronymMenuText %> ];

        var totalMenuItemsToNotBeClicked = textOfMenuItemsToNotBeClicked.length;

        while ( totalMenuItemsToNotBeClicked-- ) {

            if ( itemText.indexOf( textOfMenuItemsToNotBeClicked[totalMenuItemsToNotBeClicked] ) !== -1 ) {

                eventArgs.set_cancel( true );

            }
        }
    }
</script>


      <telerik:RadMenu ID="RadMenu1" runat="server" OnClientItemClicking="onClicking">
      ...
      </telerik:RadMenu>

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...





相关问题
How to highlight a selected item in RadMenu?

I have a RadMenu and I wish the selected item to be highlighted when clicked. But I am unable to get the desired result... Below is my code in ascx.cs file: namespace HGS.HGSAdmin.UserControl { ...

热门标签