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

Calling RadWindow from ContextMenu

4 Answers 45 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Harald Breidler
Top achievements
Rank 1
Harald Breidler asked on 13 Apr 2010, 10:08 PM
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

4 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 14 Apr 2010, 06:59 AM

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.

0
Harald Breidler
Top achievements
Rank 1
answered on 20 Apr 2010, 07:04 PM
Hi Shinu,

that was the solution!

Thank you very much,
Harald
0
Sonia
Top achievements
Rank 1
answered on 08 Oct 2013, 08:50 AM
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>



0
Kate
Telerik team
answered on 09 Oct 2013, 08:13 AM
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.
Tags
TreeView
Asked by
Harald Breidler
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Harald Breidler
Top achievements
Rank 1
Sonia
Top achievements
Rank 1
Kate
Telerik team
Share this question
or