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

RadTreeNode custom attributes gets lost

5 Answers 110 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Fahmi
Top achievements
Rank 1
Fahmi asked on 07 Jul 2011, 03:18 AM
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

5 Answers, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 12 Jul 2011, 01:41 PM
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!

0
Alexey
Top achievements
Rank 1
answered on 22 Nov 2011, 03:37 PM
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
0
Dimitar Terziev
Telerik team
answered on 25 Nov 2011, 12:49 PM
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
0
Gabriel
Top achievements
Rank 2
answered on 20 Dec 2012, 09:22 PM
I have the very same problem.

Please fix!!!!
0
Dimitar Terziev
Telerik team
answered on 24 Dec 2012, 08:16 AM
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.
Tags
TreeView
Asked by
Fahmi
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Alexey
Top achievements
Rank 1
Gabriel
Top achievements
Rank 2
Share this question
or