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

Problem in using Radtreeview in ajax panel

3 Answers 135 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
balaji
Top achievements
Rank 1
balaji asked on 27 Aug 2009, 09:16 AM
Hi ,
am balaji 

I Have used  Rad Treeview  encapsulated in a Rad ajax panel in my Project.
Here i do different transaction such as drag and drop,context menu,node click and so on.
But everything under Rad ajax panel.
Actually i have Treeview path stored as a datasource in an array.
Am assigning the Path and Storing the Value in Rad Tree node while clicking and dragging that node to destination node.

 

<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1" EnableAJAX="false" EnableHistory="false" > 
                                                <telerik:RadTreeView ID="Reportview" runat="server" AllowNodeEditing="True"    
                                                    EnableDragAndDrop="True" OnNodeExpand="RadTreeview1_NodeExpand" OnContextMenuItemClick="RadTreeView1_ContextMenuItemClick"   
                                                    OnClientNodeClicked="nodeClicked"   
                                                    OnClientContextMenuShowing="onClientContextMenuShowing"   
                                                    OnNodeEdit="RadTreeView1_NodeEdit" OnNodeDrop="RadTreeView1_HandleDrop" > 
                                                    <ContextMenus> 
                                                        <telerik:RadTreeViewContextMenu Skin="Outlook" ID="FolderContextMenu" runat="server">  
                                                           <%-- <WebServiceSettings Method="LoadFolderitems" Path="WebService.asmx" /> 
                                                             <WebServiceSettings Method="LoadReportitems" Path="WebService.asmx" />--%> 
                                                              <Items> 
                                                              <telerik:RadMenuItem Value="Create Folder" Text="Create Folder" ImageUrl="img/Outlook/10.gif">  
                                                              </telerik:RadMenuItem> 
                                                              <telerik:RadMenuItem Value="Copy Policies" Text="Copy Policies">  
                                                              </telerik:RadMenuItem> 
                                                              <telerik:RadMenuItem Value="Paste Policies" Text="Paste Policies" Enabled="false">  
                                                              </telerik:RadMenuItem> 
                                                              </Items> 
                                                        </telerik:RadTreeViewContextMenu> 
                                                          
                                                        <telerik:RadTreeViewContextMenu Skin="Outlook" ID="ReportContextMenu" runat="server">  
                                                           <%-- <WebServiceSettings Method="LoadFolderitems" Path="WebService.asmx" /> 
                                                             <WebServiceSettings Method="LoadReportitems" Path="WebService.asmx" />--%> 
                                                              <Items> 
                                                                
                                                              <telerik:RadMenuItem Value="Copy Policies" Text="Copy Policies">  
                                                              </telerik:RadMenuItem> 
                                                               <telerik:RadMenuItem Value="Paste Policies" Text="Paste Policies" Enabled="false">  
                                                              </telerik:RadMenuItem> 
                                                              </Items> 
                                                        </telerik:RadTreeViewContextMenu> 
                                                    </ContextMenus> 
                                                    <Nodes> 
                                                        <telerik:RadTreeNode runat="server" Expanded="True" ExpandMode="ServerSideCallBack" 
                                                            Text="Root" Value="/" ImageUrl="~/images/12.gif">  
                                                        </telerik:RadTreeNode> 
                                                    </Nodes> 
                                                </telerik:RadTreeView> 
                                                    
                                                <input type="hidden" id="status" runat="server" /> 
                                                <input type="hidden" id="draggednodepath" runat="server" /> 
                                                <input type="hidden" id="dropstatus" runat="server" /> 
                                                <input type="hidden" id="Nodeid" runat="server" /> 
                                               </telerik:RadAjaxPanel> 
 
In This Treeview i deal with lot of Operations such as drag and drop mcontext menu items as you can see in the Above Respective events.  
OnNodeExpand="RadTreeview1_NodeExpand" OnContextMenuItemClick="RadTreeView1_ContextMenuItemClick"   
                                                    OnClientNodeClicked="nodeClicked"   
                                                    OnClientContextMenuShowing="onClientContextMenuShowing"   
 

Here is the RadHandle_Drop Event where i assign Node value the  Path.

 
  protected void RadTreeView1_HandleDrop(object sender, RadTreeNodeDragDropEventArgs e)  
    {  
        RadTreeNode sourceNode = e.SourceDragNode;  
        RadTreeNode destNode = e.DestDragNode;  
          
        RadTreeViewDropPosition dropPosition = e.DropPosition;  
        try  
        {  
            if (sourceNode.TreeView.SelectedNodes.Count <= 1)  
            {  
                if (destNode.ToolTip != "Report")  
                {  
                    if (!sourceNode.IsAncestorOf(destNode))  
                    {  
                        string srcvalue = sourceNode.FullPath;  
                        string target = destNode.FullPath;  
 
                        if (!target.Contains(destNode.Text))  
                        {  
                            targettarget = target + destNode.Text;  
                        }  
 
                        if (srcvalue.StartsWith("Root"))  
                        {  
                            srcvaluesrcvalue = srcvalue.Replace("Root", "");  
                            //srcvaluesrcvalue=srcvalue.Substring(0,srcvalue.LastIndexOf("/"));  
                        }  
 
                        Uri uri = new Uri(Request.Cookies["reporturl"].Values["uri"].ToString());  
                        rs.Url = Request.Cookies["reporturl"].Values["uri"].ToString();  
                        NetworkCredential netCredential = new NetworkCredential(Request.Cookies["Reportcredent"].Values["Username"].ToString(), Request.Cookies["Reportcredent"].Values["pwd"].ToString(), Request.Cookies["Reportcredent"].Values["Domain"].ToString());  
                        ICredentials credential = netCredential.GetCredential(uri, "Basic");  
                        rs.Credentials = credential;  
                        if (target.LastIndexOf("/") > 0)  
                        {  
                            targettarget = target + "/" + srcvalue.Substring(srcvalue.LastIndexOf("/"));  
                            targettarget = target.Replace("//", "/").Replace("//", "/");  
                            targettarget = target.Replace("Root", "");  
                            if (sourceNode.ToolTip == "Folder")  
                            {  
                                Cache["NodeType"] = "Folder";  
                            }  
                            else  
                            {  
                                Cache["NodeType"] = "Report";  
                            }  
                        }  
                        else  
                        {  
                            if (target.StartsWith("Root"))  
                            {  
                                targettarget = target.Replace("Root", "");  
                            }  
 
 
                            target = srcvalue.Substring(srcvalue.LastIndexOf("/"));  
 
                            welcomemsg.Visible = false;  
                            if (sourceNode.ToolTip == "Folder")  
                            {  
                                Cache["NodeType"] = "Folder";  
                            }  
                            else  
                            {  
                                Cache["NodeType"] = "Report";  
                            }  
 
 
 
 
 
                        }  
 
 
 
 
 
 
 
 
 
 
                        rs.MoveItem(srcvalue, target);  
 
                        sourceNode.Owner.Nodes.Remove(sourceNode);  
                        destNode.Nodes.Add(sourceNode);  
                        draggednodepath.Value = target;  
                        destNode.Value = target;  
                         
                        destNode.Category = target;  
                        destNode.Expanded = true;  
                        dropstatus.Value = "true";  
 
                         
                    }  
 
                }  
                else  
                {  
                    welcomemsg.Visible = true;  
                    Addpane.Visible = false;  
                    rightpane.Visible = false;  
                    rightpanepolicies.Visible = false;  
                    welcomemsg.Text = "You cant Drag And Drop Report to a Report";  
                }  
                  
            }  
     
 
 
        }  
        catch (Exception ex)  
        {  
            if (ex.Message.Contains("already exists"))  
            {  
                welcomemsg.Visible = true;  
                Addpane.Visible = false;  
                rightpane.Visible = false;  
                rightpanepolicies.Visible = false;  
                welcomemsg.Text = "There cannot be a Report with the Same name in a Folder";  
            }  
            else  
            {  
                Util.LogException(ex);  
            }  
              
        }  
                sourceNode.TreeView.ClearSelectedNodes();  
    }  
 

when i try to retrieve the Exact path on some other Node Click event am not getting the Recent Value that is assigned in the Handle Drop event.
due to this am getting lot of uncertainities.
The Value is not Persistent  and not committed.
Is there any Way or code to enable it.
Can any one Help me .
Thanks
Regards
N.Balaji

 

 

3 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 28 Aug 2009, 12:41 PM
Hi balaji,

Can you recreate the problem in a simpler way so we can reproduce it locally?
Ideally, you can send us a sample running project (in a support ticket) so we can debug it.

Regards,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Chris B.
Top achievements
Rank 1
answered on 13 Nov 2009, 04:03 PM
Hi. I'm having the same problem with a Rad Treeview. When I'm dragging off a node to another node, I'm getting a different node value for my destination node, different from my targeted destination node from where I drag it off.  That's why on the refresh of the Treeview, the node relocation does not display correctly.

This issue does not occurs constantly. Sometimes, I'm getting the right destination node value, sometimes I don't.
Within the HandleDrop event, I can confirm that I'm not getting the right value.

 
protected void HandleDrop(object sender, RadTreeNodeEventArgs e) 
        { 
            RadTreeNode sourceNode = e.SourceDragNode; 
            RadTreeNode destNode = e.DestDragNode; 
            RadTreeViewDropPosition dropPosition = e.DropPosition; 
 
            if (destNode != null) 
            { 
                string DestinationNodeEntityType = destNode.Attributes["FIT"].ToString(); 
                if (DestinationNodeEntityType == "MENUITM") 
                { 
                    if (sourceNode.TreeView.SelectedNodes.Count <= 1) 
                    { 
                        PerformDragAndDrop(dropPosition, sourceNode, destNode); 
                    } 
                    else if (sourceNode.TreeView.SelectedNodes.Count > 1) 
                    { 
                        foreach (RadTreeNode node in sourceNode.TreeView.SelectedNodes) 
                        { 
                            PerformDragAndDrop(dropPosition, node, destNode); 
                        } 
                    } 
 
                    sourceNode.TreeView.ClearSelectedNodes(); 
                } 
            } 
        } 

Any help would be highly appreciated. Thanks.
0
Veselin Vasilev
Telerik team
answered on 18 Nov 2009, 01:58 PM
Hello Chris B.,

We had a similar problem before. Can you please try with the latest official build - Q3 2009 and let us know the results.

Regards,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
TreeView
Asked by
balaji
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Chris B.
Top achievements
Rank 1
Share this question
or