This question is locked. New answers and comments are not allowed.
How do I get the parent node value in the controller action for the load on demad ajax binding? I have tried node.Parent, but it is nothing/null/empty. Also, setting the content of the node is not working, and I know it is getting populated with the html, so any advice you can give there is very much appreciated as well. Thank you so much for your help!
Donna
Here's the treeview:
Here's the controller action code (I have bolded the line of code in question - it has been commented out in the code so it is in green):
Donna
Here's the treeview:
<%= Html.Telerik().TreeView().Name("ReportGroups").ShowCheckBox(True).HtmlAttributes(New With {.style = "font-size:1em; height:550px;"}) _ .ClientEvents(Function(evt) evt.OnSelect("getReports")) _ .ClientEvents(Function(evt) evt.OnLoad("setContextMenu")) _ .ClientEvents(Function(evt) evt.OnDataBound("onTreeViewLoad")) _ .ClientEvents(Function(evt) evt.OnCollapse("updateTreeViewState")) _ .ClientEvents(Function(evt) evt.OnExpand("updateTreeViewState")) _ .BindTo(CType(Model.reportGroupNames, IEnumerable(Of SelectListItem)), Sub(mappings) mappings.For(Of SelectListItem)( Sub(binding) binding _ .ItemDataBound( Sub(item, rpt) Dim isExpanded As Boolean = DirectCast(ViewData("ExpandedNodes"), String()).Contains(rpt.Text) If isExpanded Then item.Text = "<span class='expanded'></span>" + rpt.Text Else item.Text = rpt.Text End If item.Value = rpt.Value item.LoadOnDemand = True End Sub) End Sub) End Sub) _ .DataBinding(Function(dataBinding) dataBinding.Ajax().Select("GetUserGroupsForReportGroups", "Report")) %> Here's the controller action code (I have bolded the line of code in question - it has been commented out in the code so it is in green):
<AcceptVerbs(HttpVerbs.Post)> _ Function GetUserGroupsForReportGroups(ByVal node As TreeViewItem) As ActionResult Try Dim gmcPermissions As New GMCPermissions Dim groupNameKey As Integer = node.Value.Substring(node.Value.IndexOf(".") + 1) Dim nodes As New List(Of TreeViewItem) If node.Value.Substring(0, node.Value.IndexOf(".")).Equals("report") Then Dim usrGrps As List(Of WebUserGroupName) = gmcPermissions.GetWebUserGroupNamesForReportGroupName(groupNameKey) For Each usrGrp In usrGrps nodes.Add(New TreeViewItem With {.Text = "<span style='font-size:.9em;'>" + usrGrp.UserGroupName + "</span>", .Value = "usergroup." + usrGrp.UserGroupNameKey.ToString, .LoadOnDemand = True, .Encoded = False}) Next Else ' Dim ugRptInfoList As List(Of GMCListItem) = gmcPermissions.GetReportTypesForUserGroupName(node.Parent.Value.Substring(node.Parent.Value.IndexOf(".") + 1), groupNameKey) Dim ugRptInfoList As List(Of GMCListItem) = gmcPermissions.GetReportTypesForUserGroupName(48, groupNameKey) Dim taskInfo As String For Each ugRptType In ugRptInfoList taskInfo = If(NullS(ugRptType.dataObject).Equals(""), "", "%><ul><li>" + ugRptType.dataObject + "</li></ul><%") nodes.Add(New TreeViewItem With {.Text = "<span style='font-size:.9em;'>" + ugRptType.key + " " + ugRptType.value + "</span>", .Value = ugRptType.dataTag, .Encoded = False, .Content = Function() taskInfo}) Next End If Return New JsonResult With {.Data = nodes} Catch Return View("Error") End TryEnd Function