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

Context Menu "Open in new tab" - Popup Blocker problem

2 Answers 481 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
richard
Top achievements
Rank 1
richard asked on 02 Jan 2012, 04:38 PM

I am creating a radtreeview context menu with an item 'Open link in new tab'.

I have created a context menu server side and assigned it to all nodes, but problem is I need to set the NavigateURL property of the context menu and this is different for every node.

I tried using the OnClientContextMenuItemClicked and then tried using Window.Open in the javascript function:

function

ContextMenuClicked(sender, args) {

  window.open(args._node._properties._data.value,

'_blank');

}
This function get the value property of the treeview node where the URL is stored, but unfortuanetely this doesn't work because it is stopped by the IE popup blocker.

I suppose I could create a unique context menu for every single node - but there might be hundreds of nodes and I worry this would make things slow.

Please can you think of a way I can solve this problem?

Many thanks for your help

 

2 Answers, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 2
answered on 03 Jan 2012, 02:40 PM
Hello Richard,

You could use the following approach to handle your "Open In New Tab" context menu.

function OnClientContextMenuShowing(sender, args) {
    var node = args.get_node();
    var menu = args.get_menu();
      
    // get "Open In New Tab" item and set the url to use
    var openInNewTabItem = menu.findItemByValue("OpenInNewTab");
    openInNewTabItem.set_navigateUrl(node.get_navigateUrl());
}

So pretty much, I handle the OnClientContextMenuShowing event of the RadTreeView and set the NavigateUrl of the "Open In New Tab" item to the NavigateUrl of the selected node. You just need to set the Target property of the "Open In New Tab" item to _blank and everything should work as expected.

I hope that helps.
0
richard
Top achievements
Rank 1
answered on 03 Jan 2012, 05:03 PM
Hello Kevin

thanks for your reply.

That really helped me.

I had to make a couple of changes, as my url is inside the value property of the node, and I added the target = _blank to get my new tab opening.

openInNewTabItem.set_navigateUrl(node.get_value());
openInNewTabItem.set_target("_blank");

Thanks again
Tags
TreeView
Asked by
richard
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 2
richard
Top achievements
Rank 1
Share this question
or