Skip to main content

TreeView

Namespace: Wisej.Web.Ext.Syncfusion2

Assembly: Wisej.Web.Ext.Syncfusion2 (4.1.0.0)

The TreeView component is used to represent hierarchical data in a tree like structure with advanced functions to edit, drag and drop, select with CheckBox and more.

public class TreeView : ej2Base

Constructors​

Instance member TreeView()​

Constructs a new instance of the TreeView class.

Example:

The following example creates a tree view bound to hierarchical data through the Options object.

var treeView = new TreeView();
treeView.Options.fields = new
{
id = "id",
text = "name",
child = "children",
dataSource = new[]
{
new { id = "1", name = "Documents", children = new[] { new { id = "1-1", name = "Invoices" }, new { id = "1-2", name = "Contracts" } } },
new { id = "2", name = "Pictures", children = new[] { new { id = "2-1", name = "Holidays" } } }
}
};
treeView.Dock = DockStyle.Left;
this.Controls.Add(treeView);

Instance member TreeView(options)​

Constructs a new instance of the TreeView class.

NameTypeDescription
optionsObjectInitial set of options.

Example:

The following example creates a tree view with check boxes bound to self-referential data, and receives the node selected by the user.

var treeView = new TreeView(new
{
showCheckBox = true,
fields = new
{
id = "id",
parentID = "parent",
text = "name",
hasChildren = "hasChild",
dataSource = new object[]
{
new { id = 1, name = "Europe", hasChild = true },
new { id = 2, parent = 1, name = "France" },
new { id = 3, parent = 1, name = "Italy" }
}
}
});
treeView.Instance.onNodeSelected += new WidgetEventHandler((s, e) =>
{
AlertBox.Show($"Selected {e.Data.nodeData.text}");
});
treeView.Dock = DockStyle.Left;
this.Controls.Add(treeView);

Implements​