RadTreeNode custom attributes gets lost

6 posts, 0 answers
  1. Fahmi
    Fahmi avatar
    4 posts
    Member since:
    Jun 2011

    Posted 06 Jul 2011 Link to this post

    I am creating RadTreeNode as follows:

    protected RadTreeNode BuildOption(Options option, string questionType)
        {
    RadTreeNode nodeOption =
    new RadTreeNode();
     
           nodeOption.Text = "(" + option.OrderID.ToString() + ") " + option.Name;
           nodeOption.Value = option.OptionsID.ToString();
           nodeOption.Attributes.Add(SurveyTreeNodeAttributes.SurveyTreeNodeType, ((int)EnumsBL.SurveyTreeNodeType.Option).ToString());      
           nodeOption.Attributes.Add(SurveyTreeNodeAttributes.QuestionType, questionType);
           nodeOption.ImageUrl = "~/images/ConstIcons/icon-question-option.png";
           return nodeOption;
    }
    I am also loading the tree nodes on demand as follows:   
    Code Behind:
    [WebMethod]
    public static RadTreeNodeData[] LoadNodes(RadTreeNodeData node, object context)
    {
        EnumsBL.SurveyTreeNodeType nodeType = (EnumsBL.SurveyTreeNodeType)Enum.Parse(typeof(EnumsBL.SurveyTreeNodeType), node.Attributes[SurveyTreeNodeAttributes.SurveyTreeNodeType].ToString());
        TreeNodeBuilder treeNodeBuilder = QuestionnaireTreeBuilderFactory.GetQuestionnaireTreeBuilder(nodeType);
        return treeNodeBuilder.BuildChildNodesData(node.Value);
    }
    ASCX:
    <telerik:RadTreeView ID="radTree"
              Skin="Default"
              BackColor="White"
              BorderStyle="Solid"
              BorderColor="#CCCCCC"
              BorderWidth="1px"
              AllowNodeEditing="true"
              Style="cursor: hand;"
              Height="250px"
              EnableDragAndDrop="false"
              OnNodeClick="NodeClick"
               SingleExpandPath="true"
              runat="server">
             <WebServiceSettings  Path="../../Constructor/AdaptiveAnswerBuilder.aspx" Method="LoadNodes" />
          </telerik:RadTreeView>
    I have debugged method "LoadNodes" and checked that RadTreeNodeData object array contains the two attributes added to the node at the top.

    However when a node is selected I only get(after debugging) one node custom attributes, not two:
    protected void TreeNodeClicked(object sender, RadTreeNodeEventArgs e)
       {
           RadTreeNode selectedNode = e.Node; //only one of the attributes, assigned during node creation, are present
           switch ((EnumsBL.SurveyTreeNodeType)Enum.Parse(typeof(EnumsBL.SurveyTreeNodeType), selectedNode.Attributes[SurveyTreeNodeAttributes.SurveyTreeNodeType]))
           {          
               case EnumsBL.SurveyTreeNodeType.Option:
                   SetViewstateVariables(selectedNode);
                   SetConditionValueHolder(int.Parse(selectedNode.Value));
                   EnableSaveButton();
                   break;
               default:
                    pnlCondEqual.Visible = false;
                    DisableSaveButton();
                   break;
           }       
       }

    How do I get the other attribute?

    Regards,
    --Fahmi
  2. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 12 Jul 2011 Link to this post

    Hi Fahmi,

    The approach you have implemented seems right, so in order to troubleshoot this issue please provide us with the data you are binding to these custom attributes so we could test this scenario locally.

    Regards,
    Dimitar Terziev
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Alexey
    Alexey avatar
    8 posts
    Member since:
    Jun 2011

    Posted 22 Nov 2011 Link to this post

    Hi all,

    I have the same problem. The problem is that when I add an one attribute to the node of treeview, after postback count of attributes = 0. But when I add two attributes, then to the server comes one attribute not two.

    ---
    Thanks,
    Alexey
  5. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 25 Nov 2011 Link to this post

    Hi Alexey,

    I've made a sample page trying to reproduce the experienced problem, but to no avail. You could find it attached and test it locally. The tests have been performed with the latest version of the controls.

    Kind regards,
    Dimitar Terziev
    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
  6. Gabriel
    Gabriel avatar
    33 posts
    Member since:
    Apr 2011

    Posted 20 Dec 2012 Link to this post

    I have the very same problem.

    Please fix!!!!
  7. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 24 Dec 2012 Link to this post

    Hello Gabriel,

    In order to help you troubleshoot the experienced problem, please share the implementation that you are using. Additionally you could check the sample provided in my previous post.

    Greetings,
    Dimitar Terziev
    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017