Dynamic treeviews can be created on the server side or client side. When creating dynamic treeview on the server side, use a constructor to dynamically create a new instance of the C1TreeViewNode class. For client-side, the CreateInstance constructor can be used to dynamically create a new instance of the C1TreeView control. For example the follow script creates a new C1TreeView control on the client side:
var aTreeView = C1.Web.C1TreeView.createInstance ();
document.body.appendChild(aTreeView.element);
C1TreeView or C1TreeViewNode contructors can be used to create a new instance of the C1TreeView or C1TreeViewNode class. Once the nodes are created, they can be added to the Node collection of a new node or treeview.
For example:
To write the code in Visual Basic:
Visual Basic |
Copy Code
|
---|---|
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) If Not Page.IsPostBack Then Dim Pr1 As New C1TreeViewNode() Dim Oview1 As New C1TreeViewNode() Dim Down1 As New C1TreeViewNode() Dim Supp1 As New C1TreeViewNode() Dim Pr2 As New C1TreeViewNode() Dim Oview2 As New C1TreeViewNode() Dim Down2 As New C1TreeViewNode() Dim Supp2 As New C1TreeViewNode() End If |
To write the code in C#:
C# |
Copy Code
|
---|---|
protected void Page_Load(object sender, EventArgs e) if (!Page.IsPostBack) C1TreeViewNode Pr1 = new C1TreeViewNode(); C1TreeViewNode Oview1 = new C1TreeViewNode(); C1TreeViewNode Down1 = new C1TreeViewNode(); C1TreeViewNode Supp1 = new C1TreeViewNode(); C1TreeViewNode Pr2 = new C1TreeViewNode(); C1TreeViewNode Oview2 = new C1TreeViewNode(); C1TreeViewNode Down2 = new C1TreeViewNode(); C1TreeViewNode Supp2 = new C1TreeViewNode(); |