C1 Community
ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

Treeview_ItemPopulate sub not firing

rated by 0 users
This post has 1 Reply | 0 Followers

Not Ranked
Posts 5
thenrich Posted: Thu, Jan 8 2009 10:47 AM

I have added a C1WebTreeView Control to a .ASCX contol. I'm able to add some itmes in the load event just fine. The problem I'm having is that I would like the tree to create itself dynamically when I click on the main items. So I've put code in the ItemPopulate sub as soon in the examples but it never gets fired. What would casue this?

 

-Tom

 

Code:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

If Not IsPostBack Then

If Session("ResourceItem") IsNot Nothing Then

Session("CurrentPath") = Path.GetDirectoryName(CType(Session("ResourceItem"), ResourceItem).FullName)

Session("ResourceItem") = Nothing

End If

Dim thePath As String

thePath = Session("CurrentPath")

If String.IsNullOrEmpty(thePath) Then

thePath = Me._RootPath

Else

If Not thePath.EndsWith("\") Then thePath += "\"

If Not Me._RootPath.EndsWith("\") Then Me._RootPath += "\"

End If

LoadResources(thePath)

End If

End Sub

 

Private Sub LoadResources(ByVal thePath As String, Optional ByVal ItemToLoad As C1.Web.Command.C1WebTreeViewItem = Nothing)

Dim itm As C1.Web.Command.C1WebTreeViewItem

Dim rc As New ResourceCollection

rc.UserInfo = Me._UserInfo

rc.ReadPath(thePath)

For Each ri As ResourceItem In rc

itm = New C1.Web.Command.C1WebTreeViewItem

itm.PopulateOnDemand = True

itm.Text = ri.DisplayName

itm.CommandArgument = ri.FullName

If IsNothing(ItemToLoad) Then

Me.C1WebTreeView1.Items.Add(itm)

Else

If IsNothing(ItemToLoad.ChildGroup) Then ItemToLoad.CreateChildGroup()

ItemToLoad.ChildGroup.Items.Add(itm)

End If

Next

End Sub

 

Protected Sub C1WebTreeView1_ItemPopulate(ByVal sender As Object, ByVal e As C1.Web.Command.C1WebCommandEventArgs) Handles C1WebTreeView1.ItemPopulate

LoadResources(e.CommandArgument, e.Item)

End Sub

 

Top 10 Contributor
Posts 1,237
Hi,

Please use the following code:

Protected Sub C1WebTreeView1_ItemPopulate(ByVal sender As Object, ByVal e As
C1.Web.Command.C1WebCommandEventArgs) Handles C1WebTreeView1.ItemPopulate
LoadResources(path, e.Item)
End Sub

Instead of

Protected Sub C1WebTreeView1_ItemPopulate(ByVal sender As Object, ByVal e As
C1.Web.Command.C1WebCommandEventArgs) Handles C1WebTreeView1.ItemPopulate
LoadResources(e.CommandArgument, e.Item)
End Sub

Hope this helps.

Regards,
Patrick

wrote in message news:213121@10.0.1.98...
I have added a C1WebTreeView Control to a .ASCX contol. I'm able to add some
itmes in the load event just fine. The problem I'm having is that I would
like the tree to create itself dynamically when I click on the main items.
So I've put code in the ItemPopulate sub as soon in the examples but it
never gets fired. What would casue this?

-Tom

Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
If Not IsPostBack Then
If Session("ResourceItem") IsNot Nothing Then
Session("CurrentPath") =
Path.GetDirectoryName(CType(Session("ResourceItem"), ResourceItem).FullName)
Session("ResourceItem") = Nothing
End If
Dim thePath As String
thePath = Session("CurrentPath")
If String.IsNullOrEmpty(thePath) Then
thePath = Me._RootPath
Else
If Not thePath.EndsWith("\") Then thePath += "\"
If Not Me._RootPath.EndsWith("\") Then Me._RootPath += "\"
End If
LoadResources(thePath)
End If
End Sub

Private Sub LoadResources(ByVal thePath As String, Optional ByVal ItemToLoad
As C1.Web.Command.C1WebTreeViewItem = Nothing)
Dim itm As C1.Web.Command.C1WebTreeViewItem
Dim rc As New ResourceCollection
rc.UserInfo = Me._UserInfo
rc.ReadPath(thePath)
For Each ri As ResourceItem In rc
itm = New C1.Web.Command.C1WebTreeViewItem
itm.PopulateOnDemand = True
itm.Text = ri.DisplayName
itm.CommandArgument = ri.FullName
If IsNothing(ItemToLoad) Then
Me.C1WebTreeView1.Items.Add(itm)
Else
If IsNothing(ItemToLoad.ChildGroup) Then ItemToLoad.CreateChildGroup()
ItemToLoad.ChildGroup.Items.Add(itm)
End If
Next
End Sub

Protected Sub C1WebTreeView1_ItemPopulate(ByVal sender As Object, ByVal e As
C1.Web.Command.C1WebCommandEventArgs) Handles C1WebTreeView1.ItemPopulate
LoadResources(e.CommandArgument, e.Item)
End Sub




http://helpcentral.componentone.com/cs/forums/p/77811/213121.aspx#213121
Page 1 of 1 (2 items) | RSS
Contact ComponentOne: 1.800.858.2739 ©1987-2010 ComponentOne LLC All Rights Reserved.