Calling RadWindow from ContextMenu

5 posts, 1 answers
  1. Harald Breidler
    Harald Breidler avatar
    7 posts
    Member since:
    Aug 2004

    Posted 13 Apr 2010 Link to this post

    Hi,
    I use the ContextMenu in RadTreeView for add/edit/delete nodes. On inserting and editing nodes, I need some user input, in order to do some other work. Therefore I want to open a RadWindow on clicking a contextmenuitem with value of selected node as parameter.

    Could you please suggest me how to handle this scenario.

    Thanks in advance,
    Harald Breidler
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 14 Apr 2010 Link to this post

    Hello Harald Breidler,

    Attach 'OnClientContextMenuItemClicked' event to RadTreeView and in the handler, get the item clicked using 'get_menuItem()' method. Then open the window by using any of the methods described in the following documenation.

    Opening Windows

    -Shinu.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Harald Breidler
    Harald Breidler avatar
    7 posts
    Member since:
    Aug 2004

    Posted 20 Apr 2010 Link to this post

    Hi Shinu,

    that was the solution!

    Thank you very much,
    Harald
  5. Sonia
    Sonia avatar
    90 posts
    Member since:
    Mar 2012

    Posted 08 Oct 2013 Link to this post

    Hi Shinu,

    i am trying to implement OnClientContextMenuItemClicked event to RadTreeView in order to open rad window. 
    The RadWindow appears and after some milliseconds it disappears. It seems it is doing a postback, how can i cancel the postback when clicking only on specific menu items?

    Thank you.

    function onClientContextMenuItemClicked(sender, args) {
                var menuItem = args.get_menuItem();
                var treeNode = args.get_node();
                 
                switch (menuItem.get_value()) {
                    case "NewFolder":
                        {
                            $find("<%=RadWindow_AddFolder.ClientID %>").show();
                        }
                        break;
                }
            }


    <telerik:RadTreeView ID="RadTreeView1" runat="server" OnClientDoubleClick="OnClientDoubleClick"
    OnContextMenuItemClick="RadTreeView1_ContextMenuItemClick"
    OnClientContextMenuItemClicking="onClientContextMenuItemClicking" OnClientContextMenuShowing="onClientContextMenuShowing"
    OnClientContextMenuItemClicked="onClientContextMenuItemClicked"
    OnNodeExpand="RadTreeView1_NodeExpand" LoadingStatusPosition="BelowNodeText" LoadingMessage=" Loading..."
    PersistLoadOnDemandNodes="true"
    OnNodeClick="RadTreeView1_NodeClick" >               
                     <ContextMenus>
                    <telerik:RadTreeViewContextMenu ID="MyContextMenu" runat="server">
                        <Items>
                            <telerik:RadMenuItem Value="Edit" Text="Edit ..." ImageUrl="~/img/pencil.png">
                            </telerik:RadMenuItem>
                            <telerik:RadMenuItem Value="Delete" Text="Delete ..." ImageUrl="~/img/delete.png">
                            </telerik:RadMenuItem>
                            <telerik:RadMenuItem IsSeparator="true">
                            </telerik:RadMenuItem>
                            <telerik:RadMenuItem Value="NewFolder" Text="New folder" ImageUrl="~/img/new.png">
                            </telerik:RadMenuItem>
                        </Items>
                        <CollapseAnimation Type="none"></CollapseAnimation>
                    </telerik:RadTreeViewContextMenu>
                </ContextMenus>
        </telerik:RadTreeView>



  6. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 09 Oct 2013 Link to this post

    Hi Sonia,

    Try using the OnClientContextMenuItemClicking client side event that enables you cancel the postback. To achieve that you can use the following javascript code:
      function OnClientContextMenuItemClicking(sender, args) {
    //in this function you can also add your current logic
                    args.set_cancel(true);
                }


    Regards,
    Kate
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017