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

RadTreeView Control not working properly on server

6 Answers 131 Views
My glory with telerik controls
This is a migrated thread and some comments may be shown as answers.
MUNISH
Top achievements
Rank 1
MUNISH asked on 14 Aug 2012, 08:30 AM
Hi....

I am using a RadTreeView.

- Menu groups collapse when I click a sub menu item.

Expected:
- Menu group should stay open until I
click the divot to collapse the menu group
OR
click the divot to expand a different menu group
OR
go to a different tab.

This is working fine on localhost but not on server. If there is any change to be done in code while loading on server please let me know..
I am storing the value of node in session, to check if the node is clicked or not.

6 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 16 Aug 2012, 12:36 PM
Hello Munish,

In order to find what is causing this unusual behavior I will need some additional information. For your convenience I will list a couple of questions as follows:
  • Considering that your projects is working fine on localhost, could you please provide us a live url with your deployed application to investigate it locally?
  • In case you are not able to provide it, it would be really helpful if you send us a video which demonstrates the issue(you may Jing) . This is freeware screenshot and screencast software and it is really easy to use.

Regards,
Boyan Dimitrov
the Telerik team
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 their blog feed now.
0
MUNISH
Top achievements
Rank 1
answered on 16 Aug 2012, 03:16 PM
I have attached the screenshots for both the pages. One is for server and other for localhost. You can see on the left side on the local page the menu remains expandeded when add contact sub menu item is clicked but on server menu group collapses.
0
Boyan Dimitrov
Telerik team
answered on 21 Aug 2012, 12:13 PM
Hello Munish,

In your case it will be hard to inspect this problem from the provided screenshots. Could you please provide us at least one of the listed options:
  • Live URL with your deployed applications, so I can inspect that unusual behavior.
  • Sample project or demo, so I can review your code.
I hope this blog post will be helpful to send us a isolated project ready to be inspected.

Regards
Boyan Dimitrov
the Telerik team
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 their blog feed now.
0
MUNISH
Top achievements
Rank 1
answered on 22 Aug 2012, 10:26 AM
HTML code:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="InformationInfo.ascx.cs"
    Inherits="InformationInfo" %>
<%@ Register Assembly="RadTreeView.Net2" Namespace="Telerik.WebControls" TagPrefix="radT" %>
<script runat="server">
    public string MasterUrl1(string url)
    {
        return String.Format("{0}/{1}", this.TemplateSourceDirectory, url);
    }
</script>
<div class="contentBox2">
    <div class="boxTitle2">
        <asp:Image ID="Image1" ImageUrl="~/images/little-box-top-left.gif" runat="server" /><h1>
            <asp:Label ID="lblSubMenu1" Text="Home" Width="100%" runat="server" ForeColor="#FE825E"
                Font-Size="13px" Font-Bold="true" Font-Names="verdana" />
        </h1>
    </div>
    <div class="boxContent2">
        <div class="Control">
            &nbsp;<radT:RadTreeView ID="rtvTopLeftPatientMenu" Skin="Arrows/3DBlue" runat="server"
                OnNodeClick="rtvTopLeftPatientMenu_NodeClick">
            </radT:RadTreeView>
        </div>
        <br />
    </div>
    <div class="boxCap2">
        <asp:Image ID="Image2" ImageUrl="~/images/little-box-bottom-left.gif" runat="server" /></div>
</div>

Server side code :

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Data.SqlClient;



public partial class InformationInfo : System.Web.UI.UserControl
{
    clsDataUtility dUT = new clsDataUtility();
    private string _parentID = "", _subMenuHeader = "";

    public string ParentMenuID
    {
        get
        {
            return _parentID;
        }
        set
        {
            _parentID = value;
        }
    }
    public string SubMenuHeader
    {
        get
        {
            return _subMenuHeader;
        }
        set
        {
            _subMenuHeader = value;
        }
    }

    private bool _SetForPatientInformation;

    public bool SetForPatientInformation
    {
        get { return _SetForPatientInformation; }
        set { _SetForPatientInformation = value; }
    }

    private bool _SetForPOSInformation;

    public bool SetForPOSInformation
    {
        get { return _SetForPOSInformation; }
        set { _SetForPOSInformation = value; }
    }

    private bool _SetForDispenserSetupInformation;

    public bool SetForDispenserSetupInformation
    {
        get { return _SetForDispenserSetupInformation; }
        set { _SetForDispenserSetupInformation = value; }
    }
    private bool _SetForOtherInformation;

    public bool SetForOtherInformation
    {
        get { return _SetForOtherInformation; }
        set { _SetForOtherInformation = value; }
    }
    private bool _SetForSecurityInformation;

    public bool SetForSecurityInformation
    {
        get { return _SetForSecurityInformation; }
        set { _SetForSecurityInformation = value; }
    }

    private Boolean _setForUserAccessLinks = false;

    public bool SetForUserAccessLinks
    {
        get { return _setForUserAccessLinks; }
        set { _setForUserAccessLinks = value; }
    }

    private bool _SetFromStringBuilder;

    public bool SetFromStringBuilder
    {
        get { return _SetFromStringBuilder; }
        set { _SetFromStringBuilder = value; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {

        //ImagesBaseDir="../../RadControls/TreeView/Skins/Arrows/3DBlue"
        rtvTopLeftPatientMenu.ImagesBaseDir = "~/RadControls/TreeView/Skins/Arrows/3DBlue";
        if (SubMenuHeader.Length >= 22)
        {
            lblSubMenu1.Text = SubMenuHeader.Substring(0, 20) + "..";
        }
        else
        {
            lblSubMenu1.Text = SubMenuHeader;

        }
        if (!IsPostBack)
        {
            UserSession userSession = new UserSession(this.Session);

            if (SetForPatientInformation)
            {
                //    BindTreeForPatient();
                //}

                DataTable treeViewData = new DataTable();
                treeViewData = GetTreeViewData();
                AddTopTreeViewNodes(treeViewData);
            }
            if (SetForUserAccessLinks)
            {
                DataTable treeViewData = new DataTable();
                treeViewData = GetTreeViewData();
                AddTopTreeViewNodes(treeViewData);
            }

            if (SetFromStringBuilder)
            {
                BindTreeXmlString();
            }

        }



    }

    private DataTable GetTreeViewData()
    {
        UserSession userSession = new UserSession(this.Session);
        User objUser = new User();
        DataTable dt = new DataTable();
        if (userSession.UserID != "")
        {
            dt = objUser.GetHeaderMenuByUserID(Convert.ToInt32(userSession.UserID));
        }
        return dt;
    }

    /// <summary>
    /// Filter the data to get only the rows that have a
    /// null ParentID (these are the top-level TreeView items)
    /// </summary>
    private void AddTopTreeViewNodes(DataTable treeViewData)
    {
        if (ParentMenuID.Trim().Length > 0)
        {
            rtvTopLeftPatientMenu.SingleExpandPath = true;
            string sTemp = string.Empty;
            DataView view = new DataView(treeViewData);
            view.RowFilter = "Parent_Menu_ID = " + ParentMenuID;
            foreach (DataRowView row in view)
            {
                Telerik.WebControls.RadTreeNode newNode = new Telerik.WebControls.RadTreeNode(row["Menu_Description"].ToString(), row["Menu_Id"].ToString()); ;
                sTemp = row["Menu_Description"].ToString();
                if (sTemp.Trim().Length > 30)
                {
                    newNode.Text = sTemp.Substring(0, 30) + "..";

                }
                else
                {
                    if (newNode.Value == "2" || newNode.Value == "3" || newNode.Value == "6" || newNode.Value == "33" || newNode.Value == "42" || newNode.Value == "63" || newNode.Value == "84" || newNode.Value == "27" || newNode.Value == "28" || newNode.Value == "37" || newNode.Value == "41" || newNode.Value == "32" || newNode.Value == "21" || newNode.Value == "86" || newNode.Value == "87" || newNode.Value == "48" || newNode.Value == "18" || newNode.Value == "92" || newNode.Value == "93" || newNode.Value == "29" || newNode.Value == "94" || newNode.Value == "95")
                        newNode.Text = sTemp;
                    else
                        newNode.Text = sTemp + " *";  // * is provided on the link on which work is yet to be done.
                }

                newNode.ToolTip = sTemp;

                UserSession userSession = new UserSession(this.Session);


                //For Image Url has to be changed
                DataView view1 = new DataView(treeViewData);
                view1.RowFilter = "Parent_Menu_ID=" + newNode.Value;

                if (view1.Count == 0)
                {
                    newNode.ImageUrl = "BlankWhiteSpace.gif";
                }

                newNode.PostBack = true;
                newNode.NavigateUrl = row["Navigate_Url"].ToString();
                if (newNode.Value == "84")
                {
                    newNode.PostBack = false;
                    newNode.NavigateUrl = "http://www.beltone.com/locator/locator-results.aspx";
                    newNode.Target = "_blank";
                }
                rtvTopLeftPatientMenu.Nodes.Add(newNode);
                AddChildTreeViewNodes(treeViewData, newNode, 2);
                if (Session["NodeClicked"] != "" && Session["NodeClicked"] != null)
                {
                    if (newNode.Value == Session["NodeClicked"].ToString())
                    {
                        newNode.Expanded = true;
                        newNode.ExpandChildNodes();
                    }
                }

            }
        }

    }

    /// <summary>
    /// Recursively add child TreeView items by filtering by ParentID
    /// </summary>
    ///
    private void AddChildTreeViewNodes(DataTable treeViewData, Telerik.WebControls.RadTreeNode parentTreeViewNode, int levelFlag)
    {
        UserSession userSession = new UserSession(this.Session);
        DataView view = new DataView(treeViewData);
        view.RowFilter = "Parent_Menu_ID=" + parentTreeViewNode.Value;
        string strMenu_Description = string.Empty;
        string strMenu_Id = string.Empty;
        string strNavigate_Url = string.Empty;
        Telerik.WebControls.RadTreeNode newNode = null;
        foreach (DataRowView row in view)
        {
            //Telerik.WebControls.RadTreeNode newNode = new Telerik.WebControls.RadTreeNode(row["Menu_Description"].ToString(), row["Menu_Id"].ToString());
            //Telerik.WebControls.RadTreeNode newNode = new Telerik.WebControls.RadTreeNode();
            newNode = new Telerik.WebControls.RadTreeNode();
            strMenu_Id = Convert.ToString(row["Menu_Id"]);
            strMenu_Description = Convert.ToString(row["Menu_Description"]);
            strNavigate_Url = Convert.ToString(row["Navigate_Url"]);

            switch (strMenu_Id)
            {
                case "22":
                    if (Convert.ToInt32(userSession.sAuthLevel) > 3)
                    {
                        AddChildTreeViewNodesInCurrentNode(treeViewData, newNode, strNavigate_Url, strMenu_Description, strMenu_Id, parentTreeViewNode, levelFlag);
                    }
                    break;
                case "23":
                    if (Convert.ToInt32(userSession.sAuthLevel) > 3)
                    {
                        AddChildTreeViewNodesInCurrentNode(treeViewData, newNode, strNavigate_Url, strMenu_Description, strMenu_Id, parentTreeViewNode, levelFlag);
                    }
                    else
                    {
                        if (Convert.ToInt32(userSession.sAuthLevel) == 3)
                        {
                            AddChildTreeViewNodesInCurrentNode(treeViewData, newNode, strNavigate_Url, strMenu_Description, strMenu_Id, parentTreeViewNode, levelFlag);
                        }
                    }
                    break;
                case "26":
                    if (Convert.ToInt32(userSession.sAuthLevel) == 9)
                    {
                        AddChildTreeViewNodesInCurrentNode(treeViewData, newNode, strNavigate_Url, strMenu_Description, strMenu_Id, parentTreeViewNode, levelFlag);
                    }
                    break;
                case "37":
                    if (userSession.sAuth_Parts == "Y")
                    {
                        AddChildTreeViewNodesInCurrentNode(treeViewData, newNode, strNavigate_Url, strMenu_Description, strMenu_Id, parentTreeViewNode, levelFlag);
                    }
                    break;
                case "42":
                    if (userSession.sAuth_CMS == "Y")
                    {
                        AddChildTreeViewNodesInCurrentNode(treeViewData, newNode, strNavigate_Url, strMenu_Description, strMenu_Id, parentTreeViewNode, levelFlag);
                    }
                    break;
                case "48":
                    if (userSession.sAuth_BC_Rpts == "Y")
                    {
                        AddChildTreeViewNodesInCurrentNode(treeViewData, newNode, strNavigate_Url, strMenu_Description, strMenu_Id, parentTreeViewNode, levelFlag);
                    }
                    break;
                case "63":
                    if (userSession.sAuth_INT_SALES_Rpts == "Y")
                    {
                        AddChildTreeViewNodesInCurrentNode(treeViewData, newNode, strNavigate_Url, strMenu_Description, strMenu_Id, parentTreeViewNode, levelFlag);
                    }
                    break;

                //case "76":
                //    if (userSession.sAUTH_CMS_MGMT == "Y")
                //    {
                //        AddChildTreeViewNodesInCurrentNode(treeViewData, newNode, strNavigate_Url, strMenu_Description, strMenu_Id, parentTreeViewNode, levelFlag);
                //    }
                //    break;

                //case "45":
                //    if (userSession.sAUTH_TERR_MGMT == "Y")
                //    {
                //        AddChildTreeViewNodesInCurrentNode(treeViewData, newNode, strNavigate_Url, strMenu_Description, strMenu_Id, parentTreeViewNode, levelFlag);
                //    }
                //    break;
                //case "46":
                //    if (userSession.sAUTH_INC_CONTACTS == "Y")
                //    {
                //        AddChildTreeViewNodesInCurrentNode(treeViewData, newNode, strNavigate_Url, strMenu_Description, strMenu_Id, parentTreeViewNode, levelFlag);
                //    }
                //    break;
                //case "47":
                //    if (userSession.sAUTH_MKT == "Y")
                //    {
                //        AddChildTreeViewNodesInCurrentNode(treeViewData, newNode, strNavigate_Url, strMenu_Description, strMenu_Id, parentTreeViewNode, levelFlag);
                //    }
                //    break;
                default:
                    AddChildTreeViewNodesInCurrentNode(treeViewData, newNode, strNavigate_Url, strMenu_Description, strMenu_Id, parentTreeViewNode, levelFlag);
                    break;
            }

        }
    }
    private void AddChildTreeViewNodesInCurrentNode(DataTable treeViewData, Telerik.WebControls.RadTreeNode newNode, string strNavigate_Url, string strMenu_Description, string strMenu_Id, Telerik.WebControls.RadTreeNode parentTreeViewNode, int levelFlag)
    {
        if (strMenu_Id == "9" || strMenu_Id == "10" || strMenu_Id == "11" || strMenu_Id == "12" || strMenu_Id == "13" || strMenu_Id == "14" || strMenu_Id == "15" || strMenu_Id == "34" || strMenu_Id == "35" || strMenu_Id == "43" || strMenu_Id == "44" || strMenu_Id == "45" || strMenu_Id == "47" || strMenu_Id == "70" || strMenu_Id == "72" || strMenu_Id == "73" || strMenu_Id == "76" || strMenu_Id == "77" || strMenu_Id == "78" || strMenu_Id == "79" || strMenu_Id == "80" || strMenu_Id == "82" || strMenu_Id == "38" || strMenu_Id == "39" || strMenu_Id == "40" || strMenu_Id == "81" || strMenu_Id == "22" || strMenu_Id == "23" || strMenu_Id == "24" || strMenu_Id == "25" || strMenu_Id == "26" || strMenu_Id == "46" || strMenu_Id == "50" || strMenu_Id == "51" || strMenu_Id == "52" || strMenu_Id == "19" || strMenu_Id == "20" || strMenu_Id == "88" || strMenu_Id == "89" || strMenu_Id == "90" || strMenu_Id == "31" || strMenu_Id == "30" || strMenu_Id == "49" || strMenu_Id == "54" || strMenu_Id == "55" || strMenu_Id == "53" || strMenu_Id == "56" || strMenu_Id == "57" || strMenu_Id == "58" || strMenu_Id == "59" || strMenu_Id == "60" || strMenu_Id == "61" || strMenu_Id == "62" || strMenu_Id == "64" || strMenu_Id == "65" || strMenu_Id == "96" || strMenu_Id == "97" || strMenu_Id == "98" || strMenu_Id == "99" || strMenu_Id == "100" || strMenu_Id == "68")
            newNode.Text = strMenu_Description;
        else
            newNode.Text = strMenu_Description + " *"; // * is provided on the link on which work is yet to be done.
        newNode.Value = strMenu_Id;
        newNode.PostBack = true;
        newNode.NavigateUrl = strNavigate_Url;
        newNode.CssClassOver = "SecondLevelNavigationOver";
        newNode.CssClassSelect = "SecondLevelNavigationSelect";
        newNode.CssClass = "TreeNodeSecondLevelNavigation";
        parentTreeViewNode.Nodes.Add(newNode);
        AddChildTreeViewNodes(treeViewData, newNode, levelFlag + 1);
    }

    //private void AddChildTreeViewNodes(DataTable treeViewData, Telerik.WebControls.RadTreeNode parentTreeViewNode, int levelFlag)
    //{
    //    DataView view = new DataView(treeViewData);
    //    view.RowFilter = "Parent_Menu_ID=" + parentTreeViewNode.Value;
    //    foreach (DataRowView row in view)
    //    {
    //        //Telerik.WebControls.RadTreeNode newNode = new Telerik.WebControls.RadTreeNode(row["Menu_Description"].ToString(), row["Menu_Id"].ToString());
    //        Telerik.WebControls.RadTreeNode newNode = new Telerik.WebControls.RadTreeNode();
    //        newNode.Text = row["Menu_Description"].ToString();
    //        newNode.Value = row["Menu_Id"].ToString();
    //        newNode.PostBack = true;
    //        newNode.NavigateUrl = row["Navigate_Url"].ToString();
    //        newNode.CssClassOver = "SecondLevelNavigationOver";
    //        newNode.CssClassSelect = "SecondLevelNavigationSelect";
    //        newNode.CssClass = "TreeNodeSecondLevelNavigation";
    //        UserSession userSession = new UserSession(this.Session);
    //        parentTreeViewNode.Nodes.Add(newNode);
    //        AddChildTreeViewNodes(treeViewData, newNode, levelFlag + 1);
    //    }
    //}



    private void BindTreeForPatient()
    {

        StringBuilder sb = new StringBuilder();
        sb.Append("<Tree>");
        sb.Append(" <Node Text='Patient Info' ImageUrl = 'WhiteSpace.gif'  NavigateUrl='~/Patient/UpdateOriginalMarketingSource.aspx' />");
        sb.Append(" <Node Text='Incomplete Patient Registration' ImageUrl = 'WhiteSpace.gif'  NavigateUrl='~/Patient/IncompletePatientRegistration.aspx' />");
        sb.Append(" <Node Text='Consolidate Patients' ImageUrl = 'WhiteSpace.gif'  NavigateUrl='~/Patient/ConsolidateContact.aspx' />");
        sb.Append(" <Node Text='Hearing Aid Registration' ImageUrl = 'WhiteSpace.gif'  NavigateUrl='~/Patient/HearingAidRegistration.aspx' />");
        sb.Append("</Tree>");

        string xmlString = sb.ToString();
        rtvTopLeftPatientMenu.LoadXmlString(xmlString);
    }


    protected void rtvTopLeftPatientMenu_NodeClick(object o, Telerik.WebControls.RadTreeNodeEventArgs e)
    {
        if (e.NodeClicked.Parent != null)
        {
            Session["NodeClicked"] = e.NodeClicked.Parent.Value;
            try
            {
                if (e.NodeClicked.Parent.Parent.Value != null)
                {
                    Session["NodeClicked"] = e.NodeClicked.Parent.Parent.Value;
                }
            }
            catch { };
        }
        else
        {
            Session["NodeClicked"] = "";
        }
        if (e.NodeClicked.Value == "21" || e.NodeClicked.Value == "29" || e.NodeClicked.Value == "33" || e.NodeClicked.Value == "37" || e.NodeClicked.Value == "42" || e.NodeClicked.Value == "48" || e.NodeClicked.Value == "63" || e.NodeClicked.Value == "18")
        {
            e.NodeClicked.Expanded = true;
            e.NodeClicked.ExpandChildNodes();
        }
        //UserSession userSession = new UserSession(this.Session);
        //switch (e.NodeClicked.Value)
        //{
        //    case "42":
        //        userSession.NoAccessLeftSideNavigation = "InternalCMS";
        //        if (e.NodeClicked.Expanded == true)
        //        {
        //            e.NodeClicked.CollapseChildNodes();
        //            Session["NodeClicked"] = "";
        //        }
        //        else
        //            Session["NodeClicked"] = e.NodeClicked.Value;
        //        break;

        //    default:
        //        userSession.NoAccessLeftSideNavigation = "";
        //        break;
        //}
    }

    private void BindTreeXmlString()
    {
        UserSession userSession = new UserSession(this.Session);
        StringBuilder sb = new StringBuilder();
        string strTemp = String.Empty;
        //Item 4696

        if (HttpContext.Current.Request.Cookies["PatientInformation"] != null)
        {
            strTemp = HttpContext.Current.Request.Cookies["PatientInformation"].Value.ToString();
        }

        string contactId = "";
        if (Request.QueryString["Contact_Id"] != null && Request.QueryString["Contact_Id"] != "")
        {
            contactId = Request.QueryString["Contact_Id"];
        }
        else if (Request.QueryString["ContactId"] != null && Request.QueryString["ContactId"] != "")
        {
            contactId = Request.QueryString["ContactId"];
        }
        sb.Append("<!DOCTYPE r [<!ELEMENT r (#PCDATA)><!ENTITY nbsp '&#160;'>]>");
        sb.Append("<Tree>");
        bool pageAccessPermission = true;
        //pageID1 = 867;
        //pageAccessPermission = CheckSecurity(pageID1, 689);

        if (pageAccessPermission)
        {
            if (contactId != "")
            {
                sb.Append(" <Node Text='Instruments' ImageUrl = 'WhiteSpace.gif'  NavigateUrl = '~/Intranet/cms/Instruments.aspx?Contact_ID=" + contactId + "'/>");
                sb.Append(" <Node Text='Marketing Response' ImageUrl = 'WhiteSpace.gif'  NavigateUrl = '~/Intranet/cms/Marketing_History.aspx?Contact_ID=" + contactId + "'  />");
            }
        }

        sb.Append("</Tree>");

        string xmlString = sb.ToString();
        rtvTopLeftPatientMenu.LoadXmlString(xmlString);
        rtvTopLeftPatientMenu.AfterClientClick = "AfterClickHandler";
    }
}




0
MUNISH
Top achievements
Rank 1
answered on 22 Aug 2012, 12:18 PM
This is live URL

http://www.dev.beltone.com/Intranet_dev/

user id : marketing@beltone.com
pwd: testp@$$

0
Boyan Dimitrov
Telerik team
answered on 24 Aug 2012, 04:43 PM
Hello Munish,

Unfortunately we are not supporting RadControls "Classic" anymore. According to our official support policy, which can be accessed here, those controls have Extended Support state. In case there is a problem with them, we are not providing any fixes, updates and etc. Of course you could start using RadControls for Asp.net Ajax, which are  fully supported.

Independently, we were unable to run your project locally. Let me suggest you an option in your case:
  • You can send us a runnable project, which demonstrates the problem, so we can examine it at our side or deploy it to our server for further inspection.

I hope, that you will find this information helpful.


Regards,
Boyan Dimitrov
the Telerik team
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 their blog feed now.
Tags
My glory with telerik controls
Asked by
MUNISH
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
MUNISH
Top achievements
Rank 1
Share this question
or