OrgChart
Namespace: Wisej.Web
Assembly: Wisej.Framework (4.2.0.0)
Displays an interactive hierarchy of people, departments, or assets.
- C#
- VB.NET
public class OrgChart : Control
Public Class OrgChart
Inherits Control
Multiple roots form a forest. Unknown parent identities are displayed as roots until the parent is added. Root depth is zero. Branch visibility is separate from node ownership. Dragging proposes a move only on drop; the server raises NodeMoving and then NodeMoved if accepted.
Example:
var chart = new OrgChart { Dock = DockStyle.Fill, AllowDragReparent = true, CollapseBelow = 2 };
chart.Nodes.Add(new OrgNode { Id = "operations", Text = "Nadia", SubText = "VP Operations" });
chart.Nodes.Add(new OrgNode { Id = "support", ParentId = "operations", Text = "Leila" });
chart.NodeMoving += (sender, e) => e.Cancel = e.Node.Id == "operations";
Controls.Add(chart);
Constructors
OrgChart()
Creates an empty, top-down hierarchy with all branches initially expanded.
Properties
AllowDragReparent
Boolean: Gets or sets whether the user may drag a node onto a new parent; defaults to false. (Default: False)
ChartLayout
OrgChartLayout: Gets or sets the hierarchy direction, without hiding the inherited Layout event. (Default: TopDown)
CollapseBelow
Int32: Gets or sets the depth whose branches initially collapse; -1 expands all levels and roots have depth zero. (Default: -1)
Zero shows only roots. One shows roots and their children. Explicit SetExpanded calls override this default. Changing this property clears all overrides and applies the new default.
Example:
chart.CollapseBelow = 1;
chart.SetExpanded(chart.Nodes[1], true); // Open a branch at the collapsed level.
CollapseBranchText
String: Gets or sets the localized override for the "Collapse branch" text. (Default: null)
The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.
ExpandBranchText
String: Gets or sets the localized override for the "Expand branch" text. (Default: null)
The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.
Focusable
Boolean: Gets or sets whether the chart can receive the focus. The default is false. (Default: False)
Nodes
OrgNodeCollection: Gets the owned nodes in sibling and root display order.
NodeTemplate
Type: Gets or sets the concrete UserControl type used as node content, or null for the standard presentation. (Default: null)
The type needs a public parameterless constructor. OrgChart owns and disposes instances when their nodes become hidden or removed, or the template type changes. Tag receives the OrgNode; implement IOrgNodeTemplate to receive node updates. Template Size determines node geometry.
Example:
chart.NodeTemplate = typeof(EmployeeNodeControl); // UserControl implementing IOrgNodeTemplate.
ReportsText
String: Gets or sets the localized override for the "{0} reports" text. (Default: null)
The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation. {0} is the direct report count. Used for the CLDR other category of the current UI culture. Literal braces can be written as {{ and }}.
ReportText
String: Gets or sets the localized override for the "{0} report" text. (Default: null)
The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation. {0} is the direct report count. Used for the CLDR one category of the current UI culture. Literal braces can be written as {{ and }}.
TabStop
Boolean: Gets or sets whether the chart takes part in tab navigation. The default is false. (Default: False)
Methods
Dispose(disposing)
Releases subscriptions and all chart-owned templates; borrowed images and Tag remain caller-owned.
| Parameter | Type | Description |
|---|---|---|
| disposing | Boolean | Whether managed resources should be released. |
IsExpanded(node)
Gets the effective expansion state, including CollapseBelow and explicit branch overrides.
| Parameter | Type | Description |
|---|---|---|
| node | OrgNode | An owned node. |
Returns: Boolean. Whether children are shown when this node is visible.
MoveNode(node, parent)
Proposes a reparent operation through the same cancelable server events as a drop.
| Parameter | Type | Description |
|---|---|---|
| node | OrgNode | An owned node to move. |
| parent | OrgNode | An owned new parent, or null for a root. |
Returns: Boolean. True only when the move commits.
Parent may be null to promote a node to a root. Programmatic moves do not require AllowDragReparent or an enabled control. Self-parenting and cycles return false. Reentrant moves and hierarchy mutations during NodeMoving invalidate the original proposal.
Example:
chart.MoveNode(chart.Nodes[1], chart.Nodes[0]);
chart.MoveNode(chart.Nodes[1], null); // Promote to a root.
OnExpandChanged(e)
Raises ExpandChanged for subscribers and derived controls.
| Parameter | Type | Description |
|---|---|---|
| e | OrgNodeExpandEventArgs | Event data. |
OnNodeClick(e)
Raises NodeClick for subscribers and derived controls.
| Parameter | Type | Description |
|---|---|---|
| e | OrgNodeEventArgs | Event data. |
OnNodeDoubleClick(e)
Raises NodeDoubleClick for subscribers and derived controls.
| Parameter | Type | Description |
|---|---|---|
| e | OrgNodeEventArgs | Event data. |
OnNodeMoved(e)
Raises NodeMoved for subscribers and derived controls.
| Parameter | Type | Description |
|---|---|---|
| e | OrgNodeMoveEventArgs | Event data. |
OnNodeMoving(e)
Raises NodeMoving for subscribers and derived controls.
| Parameter | Type | Description |
|---|---|---|
| e | OrgNodeMoveEventArgs | Event data. |
OnWebEvent(e)
Dispatches validated client requests to dedicated processing methods.
| Parameter | Type | Description |
|---|---|---|
| e | WisejEventArgs | Client event. |
OnWebRender(config)
Renders first-level behavior properties and an atomic visible hierarchy snapshot.
| Parameter | Type | Description |
|---|---|---|
| config | Object | Client configuration. |
SetExpanded(node, expanded)
Expands or collapses a branch and raises ExpandChanged when the effective state changes.
Events
ExpandChanged
EventHandler<OrgNodeExpandEventArgs> Occurs after a branch is expanded or collapsed through SetExpanded or the client.
NodeClick
EventHandler<OrgNodeEventArgs> Occurs when a node is activated with the pointer or keyboard.
NodeDoubleClick
EventHandler<OrgNodeEventArgs> Occurs when a node is double-clicked.
NodeMoved
EventHandler<OrgNodeMoveEventArgs> Occurs after a reparent operation has been committed.
NodeMoving
EventHandler<OrgNodeMoveEventArgs> Occurs before a valid proposed reparent operation; set Cancel to reject it.
Implements
| Name | Description |
|---|---|
| IUserData | Provides access to the UserData and Tag properties associated to the component implementing this interface. |
| IBindableComponent | Bindable components implement this interface. |
| IDropTarget | Controls that support drag & drop operations implement this interface. |
| IWisejComponent | All wisej components implement this interface. |
| IWisejControl | All wisej controls derived from the Control class must implement this interface. |
| IWisejSerializable | Allows an object to serialize itself. |