Print Page | Close Window

Databind Parent Child

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=22463
Printed Date: 02 May 2024 at 6:11am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Databind Parent Child
Posted By: Skreen
Subject: Databind Parent Child
Date Posted: 19 November 2014 at 6:33am
I am trying to see if I can bind a recordset to the .DataManager of the Report control and specify the parent and child key fields so that the hierarchy is created. Currently I am just binding the recordset and then going through each row and finding the related rows and moving the child rows to the .Childs row of the parent.

manual code example

Set lstResults.DataManager.DataSource = objRecordset
lstResults.DataManager.DataBind
' go through each row
For Each objReportRow In lstResults.Rows 
    ' check for a child row with a parent Id value
    If objReportRow.Record(4).Value <> "0" Then  
        ' find the parent row
        Set objReportParentRecord = lstResults.Rows.FindRecordItemByRows(0, lstResults.Records.Count, 0, 3, 0, 0, objReportRow.Record(4).Value, xtpReportTextSearchExactPhrase)
        If Not objReportParentRecord Is Nothing Then
            Set objParentRecord = objReportParentRecord.Record
            ' move the child row to the Childs collection of the parent
            If objParentRecord.Childs.Count = 0 Then
                Call objParentRecord.Childs.InsertAt(0, objReportRow.Record)
            Else
                Call objParentRecord.Childs.InsertAt(objParentRecord.Childs.Count, objReportRow.Record)
            End If
            lstResults.Records.RemoveAt objReportRow.Index
            'objParentRecord.Expanded = True
        End If
    End If
Next
    
lstResults.Populate

would like to do it something like this:

Set lstResults.DataManager.DataSource = objRecordset
lstResults.DataManager.ParentId = objRecordset.Fields("ParentOrderNo")
lstResults.DataManager.ChildId = objRecordset.Fields("OrderNo")
lstResults.DataManager.DataBind

I know this does not exist at the minute, but is there any way to create a hierarchy in the grid when data binding?

Initial flat grid bound to recordset






















Grid after it has been reorganised




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net