Hello,
I'm using the Load On Demand Scenario & I'm attempting to force all child nodes to collapse when its parent has collapsed. Here is the code that I have so far. Any help on this would be greatly appreciated.
Private
Sub
iTeam_DynamicOrgChart_Load(sender
As
Object
, e
As
EventArgs)
Handles
Me
.Load
Dim
oConn
As
New
System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings(
"Connection"
).ConnectionString)
Dim
oCmd
As
New
SqlCommand
Dim
oData
As
SqlDataReader
Dim
oAdapter
As
New
SqlDataAdapter(oCmd)
Dim
oDataSet
As
New
DataSet
Try
oConn.Open()
'get employee hierarchy
With
oCmd
.Parameters.Clear()
.Connection = oConn
.CommandType = Data.CommandType.StoredProcedure
.CommandText =
"EmployeeHierachySP"
.Parameters.AddWithValue(
"@NameOnly"
, NameOnly.Checked)
End
With
oAdapter.Fill(oDataSet)
With
OrgChart
.DisableDefaultImage =
True
.LoadOnDemand = OrgChartLoadOnDemand.Nodes
.EnableDrillDown =
True
.PersistExpandCollapseState =
True
.DataTextField =
"UserName"
.DataFieldID =
"UserID"
.DataFieldParentID =
"ManagerUserID"
.DataCollapsedField =
"Collapsed"
.DataSource = oDataSet
'.GroupColumnCount = 4
'.GroupEnabledBinding.GroupItemBindingSettings.DataTextField = "UserName"
'.GroupEnabledBinding.GroupItemBindingSettings.DataFieldID = "UserID"
'.GroupEnabledBinding.GroupItemBindingSettings.DataFieldNodeID = "ManagerUserID"
'.GroupEnabledBinding.GroupItemBindingSettings.DataSource = oDataSet
'.GroupEnabledBinding.NodeBindingSettings.DataFieldID = "UserID"
'.GroupEnabledBinding.NodeBindingSettings.DataFieldParentID = "ManagerUserID"
'.GroupEnabledBinding.NodeBindingSettings.DataSource = oDataSet
.DataBind()
End
With
Catch
ex
As
Exception
Response.Write(ex.ToString)
Finally
oConn.Dispose()
oConn =
Nothing
oCmd =
Nothing
oData =
Nothing
oDataSet.Dispose()
oDataSet =
Nothing
oAdapter.Dispose()
oAdapter =
Nothing
End
Try
End
Sub
Protected
Sub
OrgChart_NodeDataBound(sender
As
Object
, e
As
Telerik.Web.UI.OrgChartNodeDataBoundEventArguments)
Handles
OrgChart.NodeDataBound
''e.Node.CssClass = "SmallNode"
'If e.Node.Level = 1 Then
' e.Node.Collapsed = True
'ElseIf e.Node.Level > 1 Then
' 'e.Node.Collapsed = False
'End If
e.Node.CssClass =
"Level"
& e.Node.Level
For
Each
oGroupItem
As
OrgChartGroupItem
In
e.Node.GroupItems
If
NameOnly.Checked
Then
oGroupItem.CssClass =
"SmallNodeNameOnly"
Else
oGroupItem.CssClass =
"SmallNode"
End
If
Next
End
Sub
Private
Sub
OrgChart_NodeExpandCollapse(sender
As
Object
, e
As
OrgChartNodeExpandCollapseEventArguments)
Handles
OrgChart.NodeExpandCollapse
Try
If
e.State = OrgChartNodeExpandCollapseState.NodeCollapsed
Then
For
Each
employee
As
OrgChartNode
In
e.SourceNode.Nodes
employee.Collapsed =
True
Next
End
If
Catch
ex
As
Exception
End
Try
End
Sub