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

Right mouse click is loosing selection

7 Answers 132 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Ildar
Top achievements
Rank 1
Ildar asked on 30 Aug 2011, 09:30 PM
Hello,

When user right click on RadTree node this node is highlighted.
When then user move mouse pointer to context menu the node is not highlighted.
After clicking to any context menu option there is no selected node.
In a code there still possible to find which one node triggered event and work with it.
Here is solution to fix lost node:
ASP.NET:
<telerik:RadTreeView OnContextMenuItemClick="nodeContextServerItemClicked"
 ID="treeView1" Runat="server" ></telerik:RadTreeView>
C#:
protected void nodeContextServerItemClicked(object sender, Telerik.Web.UI.RadTreeViewContextMenuEventArgs e)
{
 if(treeView1.SelectedNodes.Count < 1) e.Node.Selected = true;
}

It needs to check if the number of selected nodes less than 1 because if user selected at least one node then need really lose right clicked node.
This looks like a bug that need to be fixed from Telerik.

Sincerelly,
Ildar Sadykov

7 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 03 Sep 2011, 01:54 PM
Hi Ildar,

You can consult how this issue is handled in the Context Menu demo and consider adding this code to your project. The following code will select the desired node:

function onClientContextMenuShowing(sender, args) {
           var treeNode = args.get_node();
           treeNode.set_selected(true);
          
       }

Hope this will help.

All the best,
Plamen Zdravkov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Ildar
Top achievements
Rank 1
answered on 06 Sep 2011, 03:53 PM
Hi Plamen,

What will happen If a user select at least one node and then right click on another node?

Sincerelly,
Ildar
0
Plamen
Telerik team
answered on 08 Sep 2011, 12:45 PM
Hi Ildar,

I inspected the issue one more time and could not notice anything unusual. As it is shown in the demo, in the OnClientContextMenuShowing event we set the node which is right mouse clicked as selected.

Could you explain what is the difference in your scenario?

Kind regards,
Plamen Zdravkov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Ildar
Top achievements
Rank 1
answered on 08 Sep 2011, 10:12 PM
Hi Plamen,

I've checked one more time too on the demo you mentioned.
If a user select at least one node and then right click on another node then selected node/nodes will be lost.
It is not only unusual but it is not acceptable to lose multiple node selection feature.
And more - in the link to demo you provided is not possible to select more than one node.
At least my customers are selecting some nodes and then right clicking on another node.
In my first post there is the last checking:
if(treeView1.SelectedNodes.Count < 1)
that is fixing this bug.

Sincerelly,
Ildar
0
Accepted
Plamen
Telerik team
answered on 14 Sep 2011, 09:43 AM
Hi Ildar,

I think I didn't understand you right at the beginning, please excuse me for that. If you are actually trying to prevent the selecting of the right-clicked node instead of making it selected the code that I previously sent should not be used and your checking will work well.

Thank you for sharing this scenario with the forum.

Kind regards,
Plamen Zdravkov
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal
0
Ildar
Top achievements
Rank 1
answered on 14 Sep 2011, 08:35 PM
Hi Plamen,

I am sorry I was not so clear.
I am trying to save, keep, preserve selected by user nodes.
I am trying to implement the logic:
if user selected any node or nodes then need use them for action of context menu,
if user selected no nodes then need use a node on which right click happen.
Is it wrong logic? If not can Telerik fix it?
0
Plamen
Telerik team
answered on 16 Sep 2011, 01:21 PM
Hello Ildar,

Now I think I understand. Here is one way to make the difference whether there are selected node or not and after that do some customization in the context menu:
function onClientContextMenuShowing(sender, args) {
               var treeNode = args.get_node();
               var tree = $find("<%= RadTreeView1.ClientID %>");
               var selectedNode = tree.get_selectedNode();
               if (tree.get_selectedNode() == null) {
                 
                   alert("No selected node");
                   setMenuItemsState(args.get_menu().get_items(), treeNode);
               }
               else if (tree.get_selectedNodes()[1] == null) {
                   alert("One selected node");
                   setMenuItemsState(args.get_menu().get_items(), selectedNode);
               }
               else {
                   alert("There are selected nodes");
                   setMenuItemsState(args.get_menu().get_items(), selectedNode);
               }
           }

Hope this will be helpful.

Greetings,
Plamen Zdravkov
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal
Tags
TreeView
Asked by
Ildar
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Ildar
Top achievements
Rank 1
Share this question
or