Solved

How to add a subcategory/object to a tree (Telerik RadTreeView)

Posted on 2009-06-30
24
2,043 Views
Last Modified: 2013-11-05
Greetings,

The picture below demonstrates the goal of creating a subcategory called 'Notices' on the Telerik RadTreeView control.

My question:  What do I need to do so that I have a new subcategory called 'Notices' for every project under 'Projects' ?

I have tried to follow the code to determine how subcategories are created for each project but I'm having some difficulty.  I need help determining what code exactly populates this tree and then I need help adding an additional object.

Thanks!!
Expander-illustration.JPG
0
Comment
Question by:John500
  • 13
  • 10
24 Comments
 
LVL 3

Expert Comment

by:crittle1
ID: 24746825
I looked, I'm not able to help :(  I'm so sorry
0
 
LVL 13

Expert Comment

by:numberkruncher
ID: 24746939
How is the tree being generated?

Without any source it is very difficult to assist.
0
 

Author Comment

by:John500
ID: 24747608
>> How is the tree being generated

I was thinking I needed to place an object of some kind on the form first but I guess the objects are already placed and all I need to do is pull from the database to add additional nodes, yes/no?

How about the code below?
Load Tree Nodes

----------------
 

Protected Function KNavigator_LoadNode( _

         ByRef oDataSource As DataSet, _

         ByRef NodeParent As Telerik.Web.UI.RadTreeNode, _

         ByRef Parent_Id As Integer _

         ) As Boolean

        Try

            'Dim ie As IEnumerator = oDataSource.GetEnumerator

            'Dim e As Entity

            'ie.Reset()

            Dim t As DataTable

            t = oDataSource.Tables("Nodes")

            Dim strExpr As String

            Dim strSort As String

            strExpr = " entity_pid1 = " + Parent_Id.ToString

            ' Sort descending by column named CompanyName.

            strSort = "lexicontypeordinal,entityname "

            Dim foundRows() As DataRow
 

            foundRows = t.Select(strExpr, strSort)
 

            For Each dr As DataRow In foundRows

                Dim xNode As New Telerik.Web.UI.RadTreeNode

                'format node for given entity

                With xNode

                    .Attributes.Add("Entity_ID", dr.Item("Entity_ID").ToString)

                    .Attributes.Add("Tag", "eClass")

                    .Value = dr.Item("Entity_ID").ToString

                    .Text = dr.Item("EntityName").ToString

                    .ImageUrl = Navigator_GetImageURL(dr.Item("EntityType_Code").ToString)

                End With

                NodeParent.Nodes.Add(xNode)

                Dim ds As New DataSet

                Dim rc As nsRALPH_ENUM.DAL_ReturnCode = OK

                Dim htable As New Hashtable

                htable = CType(Session("ExpandedNode"), Hashtable)

                rc = dvl.View_SubFolders(CInt(dr.Item("Entity_ID")), ds)

                If htable IsNot Nothing Then

                    If ds.Tables(0).Rows.Count > 0 AndAlso Not htable.Contains(dr.Item("Entity_ID").ToString) Then _

                        xNode.ExpandMode = TreeNodeExpandMode.ServerSideCallBack

                    If htable.Contains(dr.Item("Entity_ID").ToString) Then

                        xNode.Expanded = True

                        xNode.ExpandMode = TreeNodeExpandMode.ServerSide

                    Else

                        xNode.Expanded = False

                    End If
 

                Else

                    If ds.Tables(0).Rows.Count > 0 Then

                        xNode.ExpandMode = TreeNodeExpandMode.ServerSideCallBack

                    End If

                End If

                _CurrentEntity = CType(Session("CurrentEntity"), Entity)

                If _CurrentEntity IsNot Nothing Then

                    If dr.Item("Entity_ID").ToString = _CurrentEntity.Entity_ID.ToString Then

                        xNode.Selected = True

                    End If

                End If

                KNavigator_LoadNode(oDataSource, xNode, CInt(dr.Item("Entity_ID").ToString))

            Next
 

            Return True

        Catch ex As Exception

            RaiseMessage(False, "Navigator_LoadNode(eZ) Exception Error: " & ex.Message)

            Return False

        End Try

    End Function

 

Open in new window

0
 
LVL 13

Accepted Solution

by:
numberkruncher earned 500 total points
ID: 24748630
Try something like the following, there are several changes that you need to make, I have indicated those using comments.
Load Tree Nodes

----------------
 

' Data structure to store both entity ID and Type!

Public Structure EntityNodeData

	Public entityID As String

	Public entityType As String
 

	Public Sub New(ByVal id As String, ByVal type As String)

		entityID = id

		entityType = type

	End Sub

End Structure
 

Protected Function KNavigator_LoadNode( _

         ByRef oDataSource As DataSet, _

         ByRef NodeParent As Telerik.Web.UI.RadTreeNode, _

         ByRef Parent_Id As Integer _

         ) As Boolean

        Try

            'Dim ie As IEnumerator = oDataSource.GetEnumerator

            'Dim e As Entity

            'ie.Reset()

            Dim t As DataTable

            t = oDataSource.Tables("Nodes")

            Dim strExpr As String

            Dim strSort As String

            strExpr = " entity_pid1 = " + Parent_Id.ToString

            ' Sort descending by column named CompanyName.

            strSort = "lexicontypeordinal,entityname "

            Dim foundRows() As DataRow

 

            foundRows = t.Select(strExpr, strSort)

 

            For Each dr As DataRow In foundRows

                Dim xNode As New Telerik.Web.UI.RadTreeNode

                'format node for given entity

                With xNode

                    .Attributes.Add("Entity_ID", dr.Item("Entity_ID").ToString)

                    .Attributes.Add("Tag", "eClass")
 

                    ' Use data structure so that both ID and Type can be accessed at a later stage.

                    .Value = New EntityNodeData(dr.Item("Entity_ID").ToString, dr.Item("EntityType_Code").ToString)

                    

                    .Text = dr.Item("EntityName").ToString

                    .ImageUrl = Navigator_GetImageURL(dr.Item("EntityType_Code").ToString)

                End With

                NodeParent.Nodes.Add(xNode)

                Dim ds As New DataSet

                Dim rc As nsRALPH_ENUM.DAL_ReturnCode = OK

                Dim htable As New Hashtable

                htable = CType(Session("ExpandedNode"), Hashtable)

                rc = dvl.View_SubFolders(CInt(dr.Item("Entity_ID")), ds)

                If htable IsNot Nothing Then

                    If ds.Tables(0).Rows.Count > 0 AndAlso Not htable.Contains(dr.Item("Entity_ID").ToString) Then _

                        xNode.ExpandMode = TreeNodeExpandMode.ServerSideCallBack

                    If htable.Contains(dr.Item("Entity_ID").ToString) Then

                        xNode.Expanded = True

                        xNode.ExpandMode = TreeNodeExpandMode.ServerSide

                    Else

                        xNode.Expanded = False

                    End If

 

                Else

                    If ds.Tables(0).Rows.Count > 0 Then

                        xNode.ExpandMode = TreeNodeExpandMode.ServerSideCallBack

                    End If

                End If

                _CurrentEntity = CType(Session("CurrentEntity"), Entity)

                If _CurrentEntity IsNot Nothing Then

                    If dr.Item("Entity_ID").ToString = _CurrentEntity.Entity_ID.ToString Then

                        xNode.Selected = True

                    End If

                End If

                KNavigator_LoadNode(oDataSource, xNode, CInt(dr.Item("Entity_ID").ToString))
 

	'******

	' TODO: 1) You will need to change "Project" to the entity type name!!

	'		2) Adjust "YOUR IMAGE PATH!" to point to an icon of some sort.

	'******

				' If parent node is a project, add notices node at end.

				Dim entityData As EntityNodeData = NodeParent.Value

                If Not entityData Is Nothing And entityData.entityType = "Project" Then

                	Dim noticesNode As New Telerik.Web.UI.RadTreeNode

                	With noticesNode

	                    .Attributes.Add("Entity_ID", dr.Item("Entity_ID").ToString)

	                    .Attributes.Add("Tag", "eClass")
 

	                    .Value = New EntityNodeData("", "ProjectNoticesNode")

	                    

	                    .Text = dr.Item("EntityName").ToString

	                    .ImageUrl = "YOUR IMAGE PATH!"

                	End With

                End If

            Next

 

            Return True

        Catch ex As Exception

            RaiseMessage(False, "Navigator_LoadNode(eZ) Exception Error: " & ex.Message)

            Return False

        End Try

    End Function

Open in new window

0
 

Author Comment

by:John500
ID: 24749470
Ok, thanks for that last post......

The page which contains this code is a master page and starts like this:

Partial Public Class BF_MasterPage
    Inherits System.Web.UI.MasterPage
    ....
    Public Structure EntityNodeData
    ...

I stuck the structure code just below this.  Sound right?

Also, I have errors where ever the assignment to the value occurs.  For instance:

 With xNode
                    .Attributes.Add("Entity_ID", dr.Item("Entity_ID").ToString)
                    .Attributes.Add("Tag", "eClass")

                    ' Use data structure so that both ID and Type can be accessed at a later stage.
                    .Value = New EntityNodeData(dr.Item("Entity_ID").ToString, dr.Item("EntityType_Code").ToString) ****** ERROR *****

                    .Text = dr.Item("EntityName").ToString
                    .ImageUrl = Navigator_GetImageURL(dr.Item("EntityType_Code").ToString)
 End With

The error:

Value of type 'BF_MasterPage.EntityNodeData' cannot be converted to 'String'.      

Your thoughts?
0
 
LVL 13

Expert Comment

by:numberkruncher
ID: 24749674
> I stuck the structure code just below this.  Sound right?

Yep, that should be fine! Place the replacement class in the same place.


> Also, I have errors where ever the assignment to the value occurs.  For instance:

Ah, I was afraid that might happen, I was hoping that "Value" was of type "Object" or "Variant". Okay, this shouldn't be a problem.

In that case, you will need to subclass the "RadTreeNode" class so that it does support what you need. This is probably a good idea anyhow, you will be able to store any information you want to with each node:
Replace the struct with the following class:

============================================

    Public Class EntityTreeNode

        Inherits RadTreeNode
 

        Public Sub New(ByVal id As String, ByVal type As String)

            EntityID = id

            EntityType = type

        End Sub
 

        Public Property EntityType() As String

            Get

                Return Me._entityType

            End Get

            Set(ByVal value As String)

                Me._entityType = value

            End Set

        End Property
 

        Public Property EntityID() As String

            Get

                Return Me._entityID

            End Get

            Set(ByVal value As String)

                Me._entityID = value

            End Set

        End Property
 

        Private _entityType As String

        Private _entityID As String

    End Class
 
 

Update your source:

===================

Protected Function KNavigator_LoadNode( _

         ByRef oDataSource As DataSet, _

         ByRef NodeParent As Telerik.Web.UI.RadTreeNode, _

         ByRef Parent_Id As Integer _

         ) As Boolean

        Try

            'Dim ie As IEnumerator = oDataSource.GetEnumerator

            'Dim e As Entity

            'ie.Reset()

            Dim t As DataTable

            t = oDataSource.Tables("Nodes")

            Dim strExpr As String

            Dim strSort As String

            strExpr = " entity_pid1 = " + Parent_Id.ToString

            ' Sort descending by column named CompanyName.

            strSort = "lexicontypeordinal,entityname "

            Dim foundRows() As DataRow

 

            foundRows = t.Select(strExpr, strSort)

 

            For Each dr As DataRow In foundRows

                Dim xNode As New EntityTreeNode

                'format node for given entity

                With xNode

                    .Attributes.Add("Entity_ID", dr.Item("Entity_ID").ToString)

                    .Attributes.Add("Tag", "eClass")

 

                    ' Use data structure of our custom node!

                    .EntityID = dr.Item("Entity_ID").ToString

                    .EntityType = dr.Item("EntityType_Code").ToString

                    

                    .Text = dr.Item("EntityName").ToString

                    .ImageUrl = Navigator_GetImageURL(dr.Item("EntityType_Code").ToString)

                End With

                NodeParent.Nodes.Add(xNode)

                Dim ds As New DataSet

                Dim rc As nsRALPH_ENUM.DAL_ReturnCode = OK

                Dim htable As New Hashtable

                htable = CType(Session("ExpandedNode"), Hashtable)

                rc = dvl.View_SubFolders(CInt(dr.Item("Entity_ID")), ds)

                If htable IsNot Nothing Then

                    If ds.Tables(0).Rows.Count > 0 AndAlso Not htable.Contains(dr.Item("Entity_ID").ToString) Then _

                        xNode.ExpandMode = TreeNodeExpandMode.ServerSideCallBack

                    If htable.Contains(dr.Item("Entity_ID").ToString) Then

                        xNode.Expanded = True

                        xNode.ExpandMode = TreeNodeExpandMode.ServerSide

                    Else

                        xNode.Expanded = False

                    End If

 

                Else

                    If ds.Tables(0).Rows.Count > 0 Then

                        xNode.ExpandMode = TreeNodeExpandMode.ServerSideCallBack

                    End If

                End If

                _CurrentEntity = CType(Session("CurrentEntity"), Entity)

                If _CurrentEntity IsNot Nothing Then

                    If dr.Item("Entity_ID").ToString = _CurrentEntity.Entity_ID.ToString Then

                        xNode.Selected = True

                    End If

                End If

                KNavigator_LoadNode(oDataSource, xNode, CInt(dr.Item("Entity_ID").ToString))

 

        '******

        ' TODO: 1) You will need to change "**Project**" to the entity type name!!

        '       2) Adjust "***YOUR IMAGE PATH!***" to point to an icon of some sort.

        '******

				' If parent node is a project, add notices node at end.

				Dim entityNode As EntityTreeNode = NodeParent

                If Not entityNode Is Nothing And entityNode.EntityType = "**Project**" Then

                        Dim noticesNode As New Telerik.Web.UI.RadTreeNode

                        With noticesNode

                            .Value = "ProjectNoticesNode"

                            .Text = "Notices"

                            .ImageUrl = "***YOUR IMAGE PATH!***"

                        End With

                End If

            Next

 

            Return True

        Catch ex As Exception

            RaiseMessage(False, "Navigator_LoadNode(eZ) Exception Error: " & ex.Message)

            Return False

        End Try

    End Function

Open in new window

0
 
LVL 13

Expert Comment

by:numberkruncher
ID: 24749688
Just to add, please note that some subtle changes have been made, like on line 57, for example:

Dim xNode As New EntityTreeNode
0
 

Author Comment

by:John500
ID: 24753700
>>  some subtle changes have been made, like on line 57, for example:

Ok, on that particular line I'm getting the following errors:

Argument not specified for parameter 'id' of 'Public Sub New(id As String, type As String)'      
Argument not specified for parameter 'type' of 'Public Sub New(id As String, type As String)'

After that I have the following two errors for the associated lines:
----------------------------------------------------------------------------------------------------------------------------------------

ERROR ON *** xNode  ***

              KNavigator_LoadNode(oDataSource, xNode, CInt(dr.Item("Entity_ID").ToString))

Option Strict On disallows narrowing from type 'Telerik.Web.UI.RadTreeNode' to type 'BF_MasterPage.EntityTreeNode' in copying the value of 'ByRef' parameter 'NodeParent' back to the matching argument.      
----------------------------------------------------------------------------------------------------------------------------------------

ERROR ON *** NodeParent ***

              Dim entityNode As EntityTreeNode = NodeParent

Option Strict On disallows implicit conversions from 'Telerik.Web.UI.RadTreeNode' to 'BF_MasterPage.EntityTreeNode'.      
----------------------------------------------------------------------------------------------------------------------------------------
0
 
LVL 13

Expert Comment

by:numberkruncher
ID: 24753803
> Ok, on that particular line I'm getting the following errors:

Please verify that you have written the following:
Public Sub New(ByVal id As String, ByVal type As String)

NOT the following:
Public Sub New(id As String, type As String)

> After that I have the following two errors for the associated lines:

Can you please post your full page code so that I can investigate?
0
 

Author Comment

by:John500
ID: 24754012
>> Can you please post your full page code so that I can investigate?

I would love to but there are 1,692 lines on this particular page if that's indeed what you are talking about.  However, I'm a little leary of the whole trade secret thing by dumping so much.

Don't you agree that although 'Inherits RadTreeNode' within the class would seem to address the original issue of type:

Dim xNode As New Telerik.Web.UI.RadTreeNode

... the ,Public Sub New()'  just doesn't agree by virtue of these two parameters

(ByVal id As String, ByVal type As String)

What am I missing?

Here's the code as it is in my project:



    Public Class EntityTreeNode

        Inherits RadTreeNode

 

        Public Sub New(ByVal id As String, ByVal type As String)

            EntityID = id

            EntityType = type

        End Sub

 

        Public Property EntityType() As String

            Get

                Return Me._entityType

            End Get

            Set(ByVal value As String)

                Me._entityType = value

            End Set

        End Property

 

        Public Property EntityID() As String

            Get

                Return Me._entityID

            End Get

            Set(ByVal value As String)

                Me._entityID = value

            End Set

        End Property

 

        Private _entityType As String

        Private _entityID As String

    End Class

 
 

Protected Function KNavigator_LoadNode( _

             ByRef oDataSource As DataSet, _

             ByRef NodeParent As Telerik.Web.UI.RadTreeNode, _

             ByRef Parent_Id As Integer _

             ) As Boolean

        Try

            'Dim ie As IEnumerator = oDataSource.GetEnumerator

            'Dim e As Entity

            'ie.Reset()

            Dim t As DataTable

            t = oDataSource.Tables("Nodes")

            Dim strExpr As String

            Dim strSort As String

            strExpr = " entity_pid1 = " + Parent_Id.ToString

            ' Sort descending by column named CompanyName.

            strSort = "lexicontypeordinal,entityname "

            Dim foundRows() As DataRow
 

            foundRows = t.Select(strExpr, strSort)
 

            For Each dr As DataRow In foundRows

                Dim xNode As New EntityTreeNode          ' ******** ERROR HERE ON xNode ********

                'format node for given entity

                With xNode

                    .Attributes.Add("Entity_ID", dr.Item("Entity_ID").ToString)

                    .Attributes.Add("Tag", "eClass")
 

                    ' Use data structure of our custom node!

                    .EntityID = dr.Item("Entity_ID").ToString

                    .EntityType = dr.Item("EntityType_Code").ToString
 

                    .Text = dr.Item("EntityName").ToString

                    .ImageUrl = Navigator_GetImageURL(dr.Item("EntityType_Code").ToString)

                End With

                NodeParent.Nodes.Add(xNode)

                Dim ds As New DataSet

                Dim rc As nsRALPH_ENUM.DAL_ReturnCode = OK

                Dim htable As New Hashtable

                htable = CType(Session("ExpandedNode"), Hashtable)

                rc = dvl.View_SubFolders(CInt(dr.Item("Entity_ID")), ds)

                If htable IsNot Nothing Then

                    If ds.Tables(0).Rows.Count > 0 AndAlso Not htable.Contains(dr.Item("Entity_ID").ToString) Then _

                        xNode.ExpandMode = TreeNodeExpandMode.ServerSideCallBack

                    If htable.Contains(dr.Item("Entity_ID").ToString) Then

                        xNode.Expanded = True

                        xNode.ExpandMode = TreeNodeExpandMode.ServerSide

                    Else

                        xNode.Expanded = False

                    End If
 

                Else

                    If ds.Tables(0).Rows.Count > 0 Then

                        xNode.ExpandMode = TreeNodeExpandMode.ServerSideCallBack

                    End If

                End If

                _CurrentEntity = CType(Session("CurrentEntity"), Entity)

                If _CurrentEntity IsNot Nothing Then

                    If dr.Item("Entity_ID").ToString = _CurrentEntity.Entity_ID.ToString Then

                        xNode.Selected = True

                    End If

                End If

                KNavigator_LoadNode(oDataSource, xNode, CInt(dr.Item("Entity_ID").ToString))  ' ******** ERROR HERE ON xNode ********
 

                '******

                ' TODO: 1) You will need to change "**Project**" to the entity type name!!

                '       2) Adjust "***YOUR IMAGE PATH!***" to point to an icon of some sort.

                '******

                ' If parent node is a project, add notices node at end.

                Dim entityNode As EntityTreeNode = NodeParent                                  ' ******** ERROR HERE ON NodeParent ********

                If Not entityNode Is Nothing And entityNode.EntityType = "Notice Templates" Then

                    Dim noticesNode As New Telerik.Web.UI.RadTreeNode

                    With noticesNode

                        .Value = "ProjectNoticesNode"

                        .Text = "Notices"

                        .ImageUrl = "~/images/main heading icon_Notices.gif"

                    End With

                End If

            Next
 

            Return True

        Catch ex As Exception

            RaiseMessage(False, "Navigator_LoadNode(eZ) Exception Error: " & ex.Message)

            Return False

        End Try

    End Function

Open in new window

0
 

Author Comment

by:John500
ID: 24754137
Maybe there is something else I can provide that doesn't include all 1,692 lines of code, yes/no?

For example, here is the code for the main load of the page or tree:
Protected Sub kNavigatorMain_Load(ByVal LocationID As Integer)

        Try

            Dim amok As Boolean = True

            Dim returnmessage As String = ""

            Dim rc As nsRALPH_ENUM.DAL_ReturnCode

            Dim setCurrentEntity As Boolean = False
 

            'Get extended Entity object for the given LocationID

            Dim eClass As New Entity

            Dim nodes_dset As New DataSet

            rc = dvl.View_TreeNodeList(_Token.LoginLocation_ID, nodes_dset)
 

            Dim def As String = Now.TimeOfDay.ToString

            'Instance My Nodes

            Dim MyNode As New Telerik.Web.UI.RadTreeNode

            MyNode.Text = "My Home Page"

            MyNode.Value = "MYHOME"

            MyNode.ImageUrl = "~/images/Nav_MyHomePage.gif"

            MyNode.Attributes.Add("Tag", _Token.LoginLocation_ID.ToString)

            Dim pNode As New Telerik.Web.UI.RadTreeNode

            With pNode

                .Text = "My Projects"

                .Value = "MYPROJECT"

                .ImageUrl = "~/images/Nav_MyProjects.gif"

                .Attributes.Add("Tag", "MYPROJECT")

            End With

            MyNode.Nodes.Add(pNode.Clone)

            Dim cNode As New Telerik.Web.UI.RadTreeNode

            With cNode

                .Text = "My Contacts"

                .Value = "MYCONTACT"

                .ImageUrl = "~/images/Nav_MyContacts.gif"

                .Attributes.Add("Tag", "MYCONTACT")

            End With

            MyNode.Nodes.Add(cNode.Clone)

            Dim aNode As New Telerik.Web.UI.RadTreeNode

            With aNode

                .Text = "Administration"

                .Value = "MYADMIN"

                .ImageUrl = "~/images/Nav_MyContacts.gif"

                .Attributes.Add("Tag", "MYADMIN")

            End With

            MyNode.Nodes.Add(aNode.Clone)

            NavigatorMain.Nodes.Add(MyNode.Clone)

            pNode = Nothing

            cNode = Nothing

            aNode = Nothing

            MyNode = Nothing
 

            'instance Root Node

            Dim Node As New Telerik.Web.UI.RadTreeNode

            Dim strExpr As String

            Dim strSort As String

            strExpr = " entity_id = " + _Token.LoginLocation_ID.ToString

            strSort = "lexicontypeordinal,entityname "
 

            Dim foundRows() As DataRow

            Dim t As DataTable

            t = nodes_dset.Tables("Nodes")

            foundRows = t.Select(strExpr, strSort)

            Dim dr As DataRow = foundRows(0)
 

            With Node

                .Attributes.Add("Entity_ID", dr.Item("Entity_ID").ToString)

                .Attributes.Add("Tag", "eClass")

                .Value = dr.Item("Entity_ID").ToString

                .Text = dr.Item("EntityName").ToString

                .ImageUrl = Navigator_GetImageURL(dr.Item("EntityType_Code").ToString)

            End With
 

		********************  CALL TO KNavigator_LoadNode() HERE ********************
 

            If amok Then _	

                amok = KNavigator_LoadNode(nodes_dset, Node, CInt(_Token.LoginLocation_ID.ToString))
 

            If amok AndAlso Node IsNot Nothing Then

                'add eClass node

                NavigatorMain.Nodes.Add(Node)
 

                'set selected node

                NavigatorMain.Nodes(0).Expanded = True

                NavigatorMain.Nodes(1).Expanded = True
 

                Select Case Me.Parent.ToString

                    Case "BF-Home"

                        Me.NavigatorMain.Nodes(1).Selected = True

                        setCurrentEntity = True

                    Case "BF-MyProjects"

                        Me.NavigatorMain.Nodes(0).Nodes(0).Selected = True

                    Case "BF-MyContacts"

                        Me.NavigatorMain.Nodes(0).Nodes(1).Selected = True

                    Case "BF-Admin"

                        Me.NavigatorMain.Nodes(0).Nodes(2).Selected = True

                End Select
 

            End If
 

            'set current entity

            If amok AndAlso setCurrentEntity Then

                If _CurrentEntity Is Nothing Then _CurrentEntity = New Entity

                amok = bll.eList_ByOption(CType(Me.NavigatorMain.SelectedNode.Value, Integer), _CurrentEntity, returnmessage)

                Session("CurrentEntity") = _CurrentEntity

            End If
 

            'clean-up

            Node = Nothing

            'Dim selectednode As New RadTreeNode

            'selectednode = CType(Session("SelectedNode"), RadTreeNode)

            'selectednode.Selected = True

        Catch ex As Exception

            RaiseMessage(False, "BuildflowMaster.NavigatorMain_Load Exception Error: " & ex.Message)

        End Try

    End Sub

Open in new window

0
 
LVL 13

Expert Comment

by:numberkruncher
ID: 24754689
>  would love to but there are 1,692 lines on this particular page if that's indeed what you are
> talking about.  However, I'm a little leary of the whole trade secret thing by dumping so much.

Sure, 1,692 would be excessive, and you should never release anything that you want to keep secret.

> What am I missing?

Actually it is something that I missed, simply change the class that you added to the following. Apologies for this error on my part.
    Public Class EntityTreeNode

        Inherits RadTreeNode

 

        Public Sub New()
 

        End Sub

 

        Public Sub New(ByVal id As String, ByVal type As String)

            EntityID = id

            EntityType = type

        End Sub

 

        Public Property EntityType() As String

            Get

                Return Me._entityType

            End Get

            Set(ByVal value As String)

                Me._entityType = value

            End Set

        End Property

 

        Public Property EntityID() As String

            Get

                Return Me._entityID

            End Get

            Set(ByVal value As String)

                Me._entityID = value

            End Set

        End Property

 

        Private _entityType As String

        Private _entityID As String

    End Class

Open in new window

0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:John500
ID: 24754992
Ok, the added Sub New() got rid of the first error but still have these two:

----------------------------------------------------------------------------------------------------------------------------------------

ERROR ON *** xNode  ***

              KNavigator_LoadNode(oDataSource, xNode, CInt(dr.Item("Entity_ID").ToString))

Option Strict On disallows narrowing from type 'Telerik.Web.UI.RadTreeNode' to type 'BF_MasterPage.EntityTreeNode' in copying the value of 'ByRef' parameter 'NodeParent' back to the matching argument.      
----------------------------------------------------------------------------------------------------------------------------------------

ERROR ON *** NodeParent ***

              Dim entityNode As EntityTreeNode = NodeParent

Option Strict On disallows implicit conversions from 'Telerik.Web.UI.RadTreeNode' to 'BF_MasterPage.EntityTreeNode'.      
----------------------------------------------------------------------------------------------------------------------------------------

Can you tell me why the compiler sees this as a conversion rather than a modification of attributes?  Isn't that what you are trying to do?
0
 
LVL 13

Expert Comment

by:numberkruncher
ID: 24755073
Have a go at the following:

Dim entityNode As EntityTreeNode = TryCast(NodeParent, EntityTreeNode)

This might address both issues,
0
 

Author Comment

by:John500
ID: 24755230
This took care of the second error.  Only this one now:

----------------------------------------------------------------------------------------------------------------------------------------

ERROR ON *** xNode  ***

              KNavigator_LoadNode(oDataSource, xNode, CInt(dr.Item("Entity_ID").ToString))

Option Strict On disallows narrowing from type 'Telerik.Web.UI.RadTreeNode' to type 'BF_MasterPage.EntityTreeNode' in copying the value of 'ByRef' parameter 'NodeParent' back to the matching argument.      
----------------------------------------------------------------------------------------------------------------------------------------

I guess the recursive aspect of this entire method doesn't like going back and forth between 'EntityTreeNode' and 'Telerik.Web.UI.RadTreeNode'  - right?
0
 

Author Comment

by:John500
ID: 24755255
Maybe this is a case of a lazy control - just doesn't want to do the work - yes/no?

Kidding
0
 
LVL 13

Expert Comment

by:numberkruncher
ID: 24755328
> Maybe this is a case of a lazy control - just doesn't want to do the work - yes/no?
rofl - funny!

> I guess the recursive aspect of this entire method doesn't like going back and forth between 'EntityTreeNode' and 'Telerik.Web.UI.RadTreeNode'  - right?

Try using the following line instead, perhaps a TryCast will work here too.

              KNavigator_LoadNode(oDataSource, TryCast(xNode, RadTreeNode), CInt(dr.Item("Entity_ID").ToString))
0
 

Author Comment

by:John500
ID: 24755820
Getting closer all the time.

I ran the code and it worked from the standpoint there were no runtime errors.  However, it only shows the icons in the far left picture below.  Thus, no subfolders are being added.

The picture on the far right shows what it normally looks like.  The fully expanded view is at the top of this question.

Can you tell me if you agree with what I see going on here:

Steps

1)  Create table for incoming dataset
2)  Sort the table and store it in foundRows() table
3)  For each row in the sorted table create a node
4)  For each node set the attributes
5)  Add the new node to the parent node
6)  Get new dataset based upon whether the database shows
    subfolders/objects for the current Entity_ID
7)  If so, add the result of the dataset to XNode
8)  If the current Entity_ID is a of type 'Notice Templates'
    add an icon to it

Did I miss anything?  I'm trying to see why the subfolders weren't added but I don't see it.  I'm also wondering why the following subnodes/folders aren't added during a normal load but this time they were:

My Projects
My Contacts
Administration

I take it there is a filter in the event there is no data to load?
tree-result.JPG
0
 

Author Comment

by:John500
ID: 24756825
Would you agree the following line needs to be included which was in the original code:

 .Value = dr.Item("Entity_ID").ToString



Current/Revised Code:

--------------------------------

With xNode

                    .Attributes.Add("Entity_ID", dr.Item("Entity_ID").ToString)

                    .Attributes.Add("Tag", "eClass")
 

                    ' Use data structure of our custom node!

                    .EntityID = dr.Item("Entity_ID").ToString

                    .EntityType = dr.Item("EntityType_Code").ToString
 

                    .Text = dr.Item("EntityName").ToString

                    .ImageUrl = Navigator_GetImageURL(dr.Item("EntityType_Code").ToString)

End With
 
 

Original Code

--------------------------

With xNode

                    .Attributes.Add("Entity_ID", dr.Item("Entity_ID").ToString)

                    .Attributes.Add("Tag", "eClass")

                    .Value = dr.Item("Entity_ID").ToString

                    .Text = dr.Item("EntityName").ToString

                    .ImageUrl = Navigator_GetImageURL(dr.Item("EntityType_Code").ToString)

End With

Open in new window

0
 
LVL 13

Expert Comment

by:numberkruncher
ID: 24759111
The only thing that I can think is that perhaps the RadTree compares each tree node instance with something internal for some reason.

Backup what you have and change the following part. If all of the project tree nodes appear again, then this is the reason why, and we will need to find another way to associate additional information with each node.

Simply change xNode back to "RadTreeNode" and remove the two indicated lines from the With xNode block. This will not fix your problem, but it will indicate whether or not this approach is going to work.
            For Each dr As DataRow In foundRows

                Dim xNode As New RadTreeNode          ' ***** CHANGE

                'format node for given entity

                With xNode

                    .Attributes.Add("Entity_ID", dr.Item("Entity_ID").ToString)

                    .Attributes.Add("Tag", "eClass")
 

        ' ***** REMOVED .EntityID and .EntityType
 

                    .Text = dr.Item("EntityName").ToString

                    .ImageUrl = Navigator_GetImageURL(dr.Item("EntityType_Code").ToString)

                End With

Open in new window

0
 

Author Comment

by:John500
ID: 24762564
I wish I could say that worked but it doesn't.  Same results as the last picture I posted.

For what ever it's worth, I included some write statements so that I could get a better idea of what's going on.  Below you can see the results given the original code and the revised.  Everything in the database is sample data in case you are wondering.

I inserted three WriteToFile() statements.

1)  First statement within  -  kNavigatorMain_Load( ... )
2)  First statement within  -  KNavigator_LoadNode( ... ) As Boolean
3)  After xNode attributes are assigned  ( seen below )

All of this may be obvious to you so forgive the extra information if it is.  Otherwise I see that for 'For Each dr As DataRow In foundRows' the revised code somehow stores two DataRows where the original does not.

Original Code
------------------------------------------------------------------------------------------------------------------------
kNavigatorMain_Load( ByVal LocationID As Integer )

KNavigator_LoadNode( ByRef oDataSource As DataSet, ByRef NodeParent As Telerik.Web.UI.RadTreeNode, ByRef Parent_Id As Integer ) As Boolean )

      Value:        317
      Text:              ABC EAST
KNavigator_LoadNode( ByRef oDataSource As DataSet, ByRef NodeParent As Telerik.Web.UI.RadTreeNode, ByRef Parent_Id As Integer ) As Boolean )

      Value:        1166
      Text:              asdfsdfewef
KNavigator_LoadNode( ByRef oDataSource As DataSet, ByRef NodeParent As Telerik.Web.UI.RadTreeNode, ByRef Parent_Id As Integer ) As Boolean )

      Value:        1168
      Text:              New Office
KNavigator_LoadNode( ByRef oDataSource As DataSet, ByRef NodeParent As Telerik.Web.UI.RadTreeNode, ByRef Parent_Id As Integer ) As Boolean )

      Value:        1184
      Text:              RyoungEun House
KNavigator_LoadNode( ByRef oDataSource As DataSet, ByRef NodeParent As Telerik.Web.UI.RadTreeNode, ByRef Parent_Id As Integer ) As Boolean )
...
...
...
125 nodes total
------------------------------------------------------------------------------------------------------------------------

Revised Code Results
------------------------------------------------------------------------------------------------------------------------
kNavigatorMain_Load( ByVal LocationID As Integer )

KNavigator_LoadNode( ByRef oDataSource As DataSet, ByRef NodeParent As Telerik.Web.UI.RadTreeNode, ByRef Parent_Id As Integer ) As Boolean )

      Value:        317
      Text:        ABC EAST
KNavigator_LoadNode( ByRef oDataSource As DataSet, ByRef NodeParent As Telerik.Web.UI.RadTreeNode, ByRef Parent_Id As Integer ) As Boolean )

      Value:        1166
      Text:        asdfsdfewef
      Value:        5
      Text:        ABC Builders
kNavigatorMain_Load( ByVal LocationID As Integer )

KNavigator_LoadNode( ByRef oDataSource As DataSet, ByRef NodeParent As Telerik.Web.UI.RadTreeNode, ByRef Parent_Id As Integer ) As Boolean )

      Value:        317
      Text:        ABC EAST
KNavigator_LoadNode( ByRef oDataSource As DataSet, ByRef NodeParent As Telerik.Web.UI.RadTreeNode, ByRef Parent_Id As Integer ) As Boolean )

      Value:        1166
      Text:        asdfsdfewef
      Value:        5
      Text:        ABC Builders

NO MORE DATA / NODES
------------------------------------------------------------------------------------------------------------------------


 

                Dim xNode As New RadTreeNode

                'format node for given entity

                With xNode

                    .Attributes.Add("Entity_ID", dr.Item("Entity_ID").ToString)

                    .Attributes.Add("Tag", "eClass")
 

                    ' Use data structure of our custom node!
 

                    .Value = dr.Item("Entity_ID").ToString

                    .Text = dr.Item("EntityName").ToString

                    .ImageUrl = Navigator_GetImageURL(dr.Item("EntityType_Code").ToString)

                End With
 

                Dim xNodeString = ControlChars.Tab + "Value:  " + ControlChars.Tab + xNode.Value.ToString() + ControlChars.NewLine + _

                                  ControlChars.Tab + "Text:  " + ControlChars.Tab + ControlChars.Tab + xNode.Text.ToString()
 

                WriteToFile("C:\ApplicationTree.txt", xNodeString + ControlChars.NewLine)

Open in new window

0
 

Author Comment

by:John500
ID: 24762768
I guess another point worth mentioning is that although the revised code appears to create six nodes ( seen with WriteToFile() ), these nodes never make it to the web page  http://#ID:24755820
0
 

Author Closing Comment

by:John500
ID: 31598363
As it turns out, a tree node would be populated by an entry to the database.  I had a feeling this was true but couldn't verify last week while a coworker was on vacation.

Thanks
0
 
LVL 13

Expert Comment

by:numberkruncher
ID: 24792867
Hi,

Sorry I was unable to respond to your last two posts. We have been without an Internet connection for 4 days due to damage caused by lightening.

Feel free to tag on links to further questions and if I can help I will.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Many programs have tried to outwit PowerPoint in terms of technology and skill. These programs, however, still lack several characteristics that PowerPoint has possessed from the start. Here's why PowerPoint replacements won't entirely work for desi…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
Learn how to create interesting presentations by including videos to keep your audience engaged using Prezi. Select "Insert" from the top menu in your Prezi editor: Select "YouTube Video": Paste the video URL into the prompt: "Select "Insert":…
In addition to being a great web-based presentation tool, Prezi also makes it easy to save your presentation as a PDF to share with others as well. Learn how in this tutorial. Select the share icon from the top menu in your Prezi editor: Select "D…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now