I am trying to load jstree checkboxes when booting using ASP. The code behind takes the node tree and populates the list item for use by jstree. In this process, there are nodes that are identified as “Verified” in which I add the jstree-clicked class attribute to the list item. However, when the page loads, it has no effect. Please let me know how to correctly set these checkboxes with pre-set checkboxes. I have the following in the background:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim tNode As TreeNode
Dim treeView As New TreeView
Dim tNodeCollection As New TreeNodeCollection
tNodeCollection = treeView.Nodes
' Code to generate and store within
' a System.Web.UI.WebControls.TreeView object
' ...
' ...
' ...
repeater.DataSource = tNodeCollection
repeater.DataBind()
End Sub
Protected Sub repeater_ItemDataBound(sender As Object, e As RepeaterItemEventArgs)
Dim tNode As TreeNode
Dim li As New HtmlGenericControl
Dim ul As New HtmlGenericControl("ul")
tNode = e.Item.DataItem
If (tNode Is Nothing) Then
Return
End If
li = e.Item.FindControl("listItem")
li.ID = tNode.Value
li.InnerHtml = tNode.Text
If tNode.Checked Then
li.Attributes.Add("rel", "true")
End If
If tNode.ChildNodes.Count > 0 Then
li.Controls.Add(ul)
searchChildNodes(tNode.ChildNodes, ul)
End If
End Sub
Private Sub searchChildNodes(childNodes As TreeNodeCollection, ul As HtmlGenericControl)
Dim tNode As TreeNode
For Each tNode In childNodes
Dim li As New HtmlGenericControl("li")
li.ID = tNode.Value
li.InnerHtml = tNode.Text
ul.Controls.Add(li)
If tNode.ChildNodes.Count > 0 Then
Dim unorderedList As New HtmlGenericControl("ul")
li.Controls.Add(unorderedList)
searchChildNodes(tNode.ChildNodes, unorderedList)
End If
Next
End Sub
The following is a piece of aspx code.
<div id="myTreeNode" >
<asp:Repeater ID="rptr" runat="server" EnableViewState="False" OnItemDataBound="repeater_ItemDataBound" >
<headerTemplate>
<ul>
</headerTemplate>
<ItemTemplate>
<li id="listItem" runat="server"></li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
</div>
source
share