Expanded Parent Node not set to [-]

6 posts, 0 answers
  1. saurabh
    saurabh avatar
    10 posts
    Member since:
    Oct 2008

    Posted 04 Jun 2009 Link to this post

    I have a tree structure with more than 2300 nodes in it. Initially my treeview was set to ExpandMode= ClientSide, but the performance was very slow. Then I changed the ExpandMode= ServerSideCallBack and my page much more responsive but it started having the issue mentioned in:-

    Is there a way to overcome this issue when ExpandMode= ServerSideCallBack?

    Thanks
    -sm.
  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 04 Jun 2009 Link to this post

    Hi saurabh,

    This should not be happening. Please refer to our online demo for additional info.

    Regards,
    Albert
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. saurabh
    saurabh avatar
    10 posts
    Member since:
    Oct 2008

    Posted 04 Jun 2009 Link to this post

    Well this is happening. Please let me know how can I upload a sample asp.net project of the problem.
  4. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 05 Jun 2009 Link to this post

    Hi saurabh,

    You need to open a support ticket in order to attach files.

    Regards,
    Albert
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. saurabh
    saurabh avatar
    10 posts
    Member since:
    Oct 2008

    Posted 05 Jun 2009 Link to this post

    Here is the code. as soon as you open the page, you will see that "child_24" is selected and all its parent's child nodes are open. But the parent node still shows "+" sign.

    //Design Page:-
    ******************************************************************************************************************************************************
    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        <asp:ScriptManager runat="server" ID="scriptManager1"></asp:ScriptManager>
        <telerik:RadComboBox ID="RadComboBoxPicker" Runat="server" Width="400px" style="vertical-align:text-bottom;">
        <ItemTemplate>
            <telerik:RadTreeView runat="server" ID="RadTreeViewPicker" OnNodeDataBound="RadTreeOnNodeDataBound" Height="400px"></telerik:RadTreeView>
        </ItemTemplate>
        <CollapseAnimation Duration="200" Type="OutQuint" />
        </telerik:RadComboBox>
        </div>
        </form>
    </body>
    </html>
    ******************************************************************************************************************************************************
    //Code Behind :-
    *********************************************************************************************************************************************************
    using System;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using Telerik.Web.UI;

    public partial class _Default : System.Web.UI.Page 
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //form a dataset with the details and expand one node.
            if (!IsPostBack)
            {
                DataTable _dt = GetData();
                RadComboBoxPicker.Items.Insert(0, new Telerik.Web.UI.RadComboBoxItem("-- Select --", "-1"));
                Telerik.Web.UI.RadTreeView tree = (Telerik.Web.UI.RadTreeView)RadComboBoxPicker.Items[0].FindControl("RadTreeViewPicker");

                tree.DataSource = _dt;
                tree.DataFieldID = "attribute_id";
                tree.DataFieldParentID = "parent_attribute_id";
                tree.DataTextField = "attribute_name";
                tree.DataValueField = "attribute_id";
                tree.DataBind();

                ExpandDefaultNode();

            }
        }


        protected void ExpandDefaultNode()
        {
            Telerik.Web.UI.RadTreeView tree = (Telerik.Web.UI.RadTreeView)RadComboBoxPicker.Items[0].FindControl("RadTreeViewPicker");
            RadTreeNode _node = tree.FindNodeByValue("24");
            if (_node != null)
            {
                _node.Selected = true;
                _node.ExpandParentNodes();
                RadComboBoxPicker.SelectedItem.Text = _node.Text;
            }

        }

        protected DataTable GetData()
        {
            DataTable _dt = new DataTable();
            DataColumn _dc1 = new DataColumn("Attribute_Id");
            DataColumn _dc2 = new DataColumn("Attribute_Name");
            DataColumn _dc3 = new DataColumn("Parent_Attribute_Id");
            DataColumn _dc4 = new DataColumn("Has_Children");

            _dt.Columns.Add(_dc1);
            _dt.Columns.Add(_dc2);
            _dt.Columns.Add(_dc3);
            _dt.Columns.Add(_dc4);

            DataRow _dr = _dt.NewRow();
            _dr["Attribute_Id"] = 1;
            _dr["Attribute_Name"] = "Parent1";
            _dr["Parent_Attribute_Id"] = null;
            _dr["Has_Children"] = "Y";
            _dt.Rows.Add(_dr);

            _dr = _dt.NewRow();
            _dr["Attribute_Id"] = 2;
            _dr["Attribute_Name"] = "Parent2";
            _dr["Parent_Attribute_Id"] = null;
            _dr["Has_Children"] = "Y";
            _dt.Rows.Add(_dr);

            _dr = _dt.NewRow();
            _dr["Attribute_Id"] = 3;
            _dr["Attribute_Name"] = "Parent3";
            _dr["Parent_Attribute_Id"] = null;
            _dr["Has_Children"] = "Y";
            _dt.Rows.Add(_dr);

            for (int _outer = 1; _outer < 4; _outer++)
            {
                for (int _inner = 1; _inner < 6; _inner++)
                {
                    _dr = _dt.NewRow();
                    _dr["Attribute_Id"] = _outer*10+_inner;
                    _dr["Attribute_Name"] = "Child_" + (_outer * 10 + _inner).ToString();
                    _dr["Parent_Attribute_Id"] = _outer;
                    _dr["Has_Children"] = "N";
                    _dt.Rows.Add(_dr);
                }
            }
            return _dt;
        }

        protected void RadTreeOnNodeDataBound(object sender, Telerik.Web.UI.RadTreeNodeEventArgs e)
        {
            if ((((DataRowView)e.Node.DataItem)["Has_Children"]).ToString().Equals("Y"))
            {
                e.Node.ExpandMode = TreeNodeExpandMode.ServerSideCallBack;
            }
        }
    }
    *********************************************************************************************************************************************************
  6. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 10 Jun 2009 Link to this post

    Hi saurabh,

    If a node's expand mode is set to ServerSideCallBack - then the plus sign will be shown until the node is expanded by the user (or the expand() javascript method is called). This is by design.


    Greetings,
    Veselin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top