Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
170
How to use ultrawinTree with results coming back from SQl server stored procedure
posted

Still very new to suing infragistic controls. Now trying to add Ultratree to a windows form and have it get populated with results from stored procedure.  attached is picture of results. Most records of Area have only 1 value but some do have 2 or more userId's.

I am trying to have first column in tree show just the areas and the req field. Then would expand on click to show userID and picks

I have always binded control to the results but doesn't seem to work here. Where would I start after calling the stored procedure to define the nodes of the tree. I know I am being vague but having much difficulty understanding where to begin.

Parents
No Data
Reply
  • 170
    Offline posted

    I am getting somewhere. I can now display what I am looking for data wise. only is that I on load only want to see the first two columns. In case of CGR I would only want to see one line but a + expand sign next to it and clicking that would show the two record of different userID and picks. How do handle that. The code  in zip is hiding the last two columns like I want but can't expand to see child nodes.

    Imports System.Data.SqlClient
    
    Imports Infragistics.Win.UltraWinTree
    Imports Infragistics.Win
    
    Public Class Form1
    
        Private ds As New DataSet
        Private dt As New DataTable
        Private da As New SqlDataAdapter
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Dim dt As Date = "01/16/2020"
            Dim cmd As New SqlCommand
    
            Using sqlcon As New SqlConnection("User ID=sa;password=grsi;Initial Catalog=mrdata;Data Source=manageright")
                Try
                    sqlcon.Open()
                Catch ex As Exception
    
                End Try
    
                With cmd
                    .Connection = sqlcon
                    .CommandType = CommandType.StoredProcedure
                    .CommandText = "prdatarpt.spPicksByUserInArea"
                    .Parameters.Clear()
                    .Parameters.AddWithValue("@DelDate", dt)
                    da.SelectCommand = cmd
                    da.Fill(ds, "Areas")
                End With
    
    
            End Using
            Try
                GetData()
                With Me.UT1
                    .ViewStyle = UltraWinTree.ViewStyle.Default
                    .ColumnSettings.AutoFitColumns = AutoFitColumns.ResizeAllColumns
                    .ColumnSettings.ShowBandNodes = ShowBandNodes.OnlyForSiblingBands
                    .SetDataBinding(ds, "Areas")
                End With
            Catch ex As Exception
                MessageBox.Show(ex.Message)
            End Try
    
    
    
    
        End Sub
    
        Private Function GetData() As Integer
            Dim theProject As DataTable = ds.Tables.Add("Pickareas")
            theProject.Columns.Add("Area", GetType(String))
            theProject.Columns.Add("REQ", GetType(Integer))
            theProject.Columns.Add("User", GetType(String))
            theProject.Columns.Add("Picks", GetType(Integer))
    
            theProject.Rows.Add(New Object())
    
            Dim theUsers As DataTable = ds.Tables.Add("Users")
            theUsers.Columns.Add("USer", GetType(String))
            theUsers.Columns.Add("Pick", GetType(Integer))
    
    
        End Function
    
    #Region " ColumnSet Generated "
        Private Sub ultraTree1_ColumnSetGenerated(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinTree.ColumnSetGeneratedEventArgs) Handles UT1.ColumnSetGenerated
    
    
    
            If e.ColumnSet.Key = "Areas" Then
                e.ColumnSet.NodeTextColumn = e.ColumnSet.Columns("UserID")
            End If
    
            If e.ColumnSet.Key = "Areas" Then
                For Each _col As UltraWinTree.UltraTreeNodeColumn In e.ColumnSet.Columns
                    _col.Visible = False
                Next
    
                e.ColumnSet.Columns("Area").Visible = True
                e.ColumnSet.Columns("REQ").Visible = True
    
                e.ColumnSet.NodeTextColumn = e.ColumnSet.Columns("UserID")
            End If
        End Sub
    #End Region
    
    #Region " uT1_InitializeDataNode "
        Private Sub UT1_InitializeDataNode(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinTree.InitializeDataNodeEventArgs) Handles UT1.InitializeDataNode
            If e.Node.Parent Is Nothing Then
                e.Node.Expanded = True
            End If
        End Sub
    #End Region
    
    #Region " ultraTree1_AfterDataNodesCollectionPopulated "
        Private Sub uT1_AfterDataNodesCollectionPopulated(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinTree.AfterDataNodesCollectionPopulatedEventArgs) Handles UT1.AfterDataNodesCollectionPopulated
            Dim column As UltraTreeNodeColumn
            For Each column In e.Nodes.ColumnSetResolved.Columns
                column.PerformAutoResize()
            Next
        End Sub
    #End Region
    End Class
    

Children