I’ve been goolgled for a copuple of weeks ago on how to display multi-column in web treeview. Unforetunately I didn’t find any control that meets my reqirement
But I found out a simple way to show multi-column in treeview.
Here’s a simple sample on how to show multi-column data in web Treeview (MS IE Web Controls).
But have some limitations. So it’s not very good
It doesn’t support for n-levels tree hierarchy and it depends on the treeNode’s text also.
If the treeNode’s Text is so long, then ur tree’s nest level also decrease.
But anyway, it might useful for people who wanna display data in multi-column format and the tree depth is not high. Hope it might give some help for u guys…Here’s the some sample code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadIf Not Page.IsPostBack ThenobjTreeView.SystemImagesPath = Server.MapPath(”~/TreeRef/webctrl_client/1_0/treeimages/”)
PopulateTree()
End If
End SubPrivate Sub PopulateTree()Dim objRoot As New Microsoft.Web.UI.WebControls.TreeNode
objRoot.Text = “Root”
objRoot.ImageUrl = Server.MapPath(”../Images/Tree/Glob.gif”)
objTreeView.Nodes.Add(objRoot)
LoadSubChild(objRoot, 10)
objTreeView.DataBind()
End Sub
Private Sub LoadSubChild(ByVal objRoot As Microsoft.Web.UI.WebControls.TreeNode, ByVal childCount As Integer)
‘Add first level 100 childsDim i As Integer
For i = 0 To childCount
Dim objFChild As New Microsoft.Web.UI.WebControls.TreeNode
‘Calculat the treenode level
Dim iLevel As Integer = GetTreeNodeLevel(objRoot)
Dim _MaxWidth As Integer = 1000
Dim iWidth As Integer = iLevel * 19
Dim _tableWidth As String = CType((_MaxWidth – iWidth), String) + “px”
Dim _col1Text As StringIf (_MaxWidth – iWidth) – 600 <= 10 Then
_col1Text = “…”Else
_col1Text = “Child” + i.ToString
End If
Dim _Col1Width As String = CType((_MaxWidth – iWidth) – 600, String) + “px”
Dim _Col2Width As String = “200px”
Dim _Col3Width As String = “200px”Dim _Col4Width As String = “200px”
Dim str As String = “<table cellspacing=’0′ cellpadding=’0′ border=’0′ width=” + _tableWidth.ToString + “height=’100%’><tr><td style=’width:” + _Col1Width.ToString + “‘>” + _col1Text.ToString + “</td><td style=’width:” + _Col2Width.ToString + “‘>Col 2</td><td style=’width:” + _Col3Width.ToString + “‘>Col 3</td><td style=’width:” + _Col4Width.ToString + “‘>Col 4</td></tr></table>”objFChild.Text = str‘Set file and folder alternately.
objFChild.ImageUrl = Server.MapPath(”../Images/Tree/folder.gif”)
objFChild.Expandable = Microsoft.Web.UI.WebControls.ExpandableValue.Always
objRoot.Nodes.Add(objFChild)
Next
End SubPrivate Function GetTreeNodeLevel(ByVal objRoot As Microsoft.Web.UI.WebControls.TreeNode) As Integer
Dim count As Integer
Do While objRoot.Parent.GetType Is GetType(Microsoft.Web.UI.WebControls.TreeNode)
count += 1If Not IsNothing(objRoot.Parent) Then
objRoot = objRoot.Parent
Else
Exit Do
End If
Loop
Return count
End Function
Private Sub objTreeView_Expand(ByVal sender As Object, ByVal e As Microsoft.Web.UI.WebControls.TreeViewClickEventArgs) Handles objTreeView.Expand
If Not e.Node = “0″ Then
‘Load the subchild nodes
Dim str As System.Text.StringBuilder
LoadSubChild(objTreeView.GetNodeFromIndex(e.Node), 5)
End If
End Sub
I think, IE Web Control doesn’t work well in Firefox and some other kinda browsers.
Yes…it might not worked for some other browsers.
But as far as I’ve tested, it’s working with Firefox 1.0.7.
But the style applied doens’t show properly.
Actually IE Web Control is under test.
We have web treeview in VS 2005 with more features. So actually we should move to 2005.
But for some ppl who needs to stick with 2003 like me , it’s an alternative solution if we don’t wanna use third-party controls and also don’t wanna write own custom treeview.
Here is one that is a multi-column TreeView for the web. I think it is new:
http://www.DigitalTools.com
very interesting, but I don’t agree with you
Idetrorce