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

setting attributes in NodeExpand

3 Answers 65 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Martin Smith
Top achievements
Rank 1
Martin Smith asked on 26 Mar 2010, 03:12 PM
On the Page_Load the Attribute IS set correctly.

So that on NodeExpand of the top level the myPC node is created.

However, the Attributes.Add in NodeExpand does not set the attributes.

Therefore NEXT time it comes into expand, Drive node is NOT created.

Is this a bug?

protected void Page_Load(object sender, EventArgs e) 
     if (!Page.IsPostBack) 
     { 
           RadTreeNode rootNode = new RadTreeNode("Computers"); 
           rootNode.Attributes.Add("type""ROOT"); 
           rootNode.Value = "ROOT"
           rootNode.ImageUrl = "~/TreeView/Img/WindowsXP/6myNetworkPlaces.gif"
           rootNode.Expanded = true
           rootNode.ExpandMode = TreeNodeExpandMode.ServerSideCallBack; 
           RadTreeView1.Nodes.Add(rootNode); 
     } 
}  
 
protected void RadTreeView1_NodeExpand(object sender, RadTreeNodeEventArgs e) 
            if (e.Node.Attributes["type"] == "ROOT"
            { 
 
                RadTreeNode node = new RadTreeNode("mypc"); 
                node.Attributes.Add("type""COMPUTER"); 
                node.Value = "COMPUTER";          
                node.ImageUrl = "~/TreeView/Img/WindowsXP/2PCRemote.gif"
                node.ExpandMode = TreeNodeExpandMode.ServerSideCallBack; 
                e.Node.Nodes.Add(node); 
 
                return
            } 
 
            if (e.Node.Attributes["type"] == "COMPUTER"
            { 
 
                RadTreeNode node = new RadTreeNode("C"); 
                node.Attributes.Add("type""DRIVE"); 
                node.Value = "DRIVE"
                node.ImageUrl = "~/TreeView/Img/WindowsXP/15hardDisk.gif"
                node.ExpandMode = TreeNodeExpandMode.ServerSideCallBack; 
                e.Node.Nodes.Add(node); 
            } 
 

3 Answers, 1 is accepted

Sort by
0
Veronica
Telerik team
answered on 26 Mar 2010, 04:37 PM
Hi Martin Smith,

The only problem in your project is using the "type" keyword for Custom Attributes. You should avoid using names of custom attributes which are valid html attributes. I just replaced the "type" with "type1" and the project is working now.

You may read this article for a list of some of the custom attributes you should avoid.

Hope this helps.

Regards,
Veronica Milcheva
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Martin Smith
Top achievements
Rank 1
answered on 28 Mar 2010, 03:47 AM
hmmm, still doesn't work for me.
0
Veronica
Telerik team
answered on 29 Mar 2010, 01:41 PM
Hi Martin Smith,

I'm attaching the edited code as a .zip file. You may try it on your own.

It works OK by only changing the custom attributes from  "type" to "type1".

Hope this helps.

Kind regards,
Veronica Milcheva
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
TreeView
Asked by
Martin Smith
Top achievements
Rank 1
Answers by
Veronica
Telerik team
Martin Smith
Top achievements
Rank 1
Share this question
or