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

[Solved] Programmatically Create Custom Nodes

2 Answers 222 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Ed Bassin
Top achievements
Rank 1
Ed Bassin asked on 26 Jun 2008, 06:14 PM
Hello,

I'm loading a tree from my database inside of Page Load with the following code:

   if (!Page.IsPostBack) { 
            string query = "SELECT id, node_name, node_type,"
                " default_value, attributes, parent_id FROM default_tree"; 
            dataSource = MyMasterPage.executeSQLQuery(query); 
            Hashtable hash = new Hashtable(); 
            foreach (DataRow dr in dataSource.Rows) { 
                int id = Convert.ToInt32(dr["id"]); 
                string node_name = dr["node_name"].ToString(); 
                string node_type = dr["node_type"].ToString(); 
                string value = dr["default_value"].ToString(); 
                string attributes = dr["attributes"].ToString(); 
                int parent_id = Convert.ToInt32(dr["parent_id"]); 
                RadTreeNode node = new RadTreeNode(node_name); 
               
               //here I want to be able to customize the node 
                node.Value = parent_id + ';' + node_type + ';' + value + ';' + attributes; 
                hash.Add(id, node); 
                if (parent_id == 0) { 
                    optionsTree.Nodes.Add(node); 
                } else { 
                    RadTreeNode parent = (RadTreeNode)hash[parent_id]; 
                    parent.Nodes.Add(node); 
                } 
            } 
        } 


Based on the node_type value, I want to change the node in the tree.

The possible special node types are:
List (drop down list)
Header (uneditable)
Number (textfield)
String (textfield)
Password (passwordfield)
Boolean (checkbox)

How do I change the type of node that this is in the tree?  I tried to figure out how to add a custom template here but couldn't figure it out.

Thanks

2 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 27 Jun 2008, 10:51 AM
Hello Ed Bassin,

Have you tried to implement this goal using templates at runtime? I believe that this article will get you started:
Adding and Editing Templates at Runtime


Greetings,
Veskoni
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Ed Bassin
Top achievements
Rank 1
answered on 27 Jun 2008, 01:52 PM
thank you
Tags
TreeView
Asked by
Ed Bassin
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Ed Bassin
Top achievements
Rank 1
Share this question
or