Print Page | Close Window

Looping through ALL rows

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=17610
Printed Date: 22 November 2024 at 5:49am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Looping through ALL rows
Posted By: markmark
Subject: Looping through ALL rows
Date Posted: 27 November 2010 at 9:52am

 

Hi

 

Is there a nice simple way that I can loop through all the rows on the grid.

Even if there are Child items as well. or even lots of childs of child (a child is a parent item)

 

I note that wndReportControl.Rows.Count  changes if the parent is expanded, if its not the count doesn't include the childs.

 

So this is simple, but no good if a parent is closed up

For lngRow = 0 To wndReportControl.Rows.Count - 1

              value = value  & wndReportControl.Rows.Row(lngRow).Record.Item(2).Value

 

Next

This method ignores child completely

For Each rRecord In wndReportControl.Records

 

Next

 

so you end up doing tests like,  

For Each rRecordChild In rRecord.Childs

Next

 

Does any one know of a better way

 

Many Thanks

 

Mark

 



-------------
Product: Xtreme SuitePro (ActiveX) version 13.0.0
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0



Replies:
Posted By: Aaron
Date Posted: 28 November 2010 at 3:16am
Hi,
 
You would expect that for each loop would work on records but it doesn't... Well, you could create function and loop child records recursively, something like this:
 
Private Function IterateReportCollection()
    Dim xtremeRecord As XtremeReportControl.ReportRecord
        
    For Each xtremeRecord In Me.wndReportControl.Records
        'Checking goes here
        If xtremeRecord.Childs.Count > 0 Then 'found record with child(s), so first check the child(s)
            IterateChilds xtremeRecord
        End If
    Next xtremeRecord
   
End Function
 
Private Function IterateChilds(xtremeRecordParent As XtremeReportControl.ReportRecord)
   
    Dim xtremeRecord As XtremeReportControl.ReportRecord
   
    For Each xtremeRecord In xtremeRecordParent.Childs
        'Checking goes here
        If xtremeRecord.Childs.Count > 0 Then 'found record with child(s), so first check the child(s)  
            IterateChilds xtremeRecord
        End If
    Next xtremeRecord   

End Function
 
Good luck Wink
 


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....


Posted By: markmark
Date Posted: 28 November 2010 at 8:06am
Thanks you Aaron.
 
Its a shame it can't be done!
Where AllRecords includes childs.
 For Each xtremeRecord In Me.wndReportControl.AllRecords

 Next xtremeRecord

Again thanks for your help, this forum would be very dead without you!

Mark


-------------
Product: Xtreme SuitePro (ActiveX) version 13.0.0
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0


Posted By: Aaron
Date Posted: 28 November 2010 at 8:40am
Originally posted by markmark markmark wrote:

Thanks you Aaron.
 
Its a shame it can't be done!
Where AllRecords includes childs.
 For Each xtremeRecord In Me.wndReportControl.AllRecords

 Next xtremeRecord
[...]
 
Hi Mark,
 
First of all I didn't know that child records weren't part of Record collection because I never used parent/childs in RC. I'm glad I read your post again because I wanted to answer: just iterate Record collection instead of Row collection LOL btw I also benefit from such questions in forum, now I know this can't be done and I definitely don't use parent records and I will stick to my own design where adding ordinary records and assigning GroupCaptions to those records which I want to group (same as parent/childs Wink
 
So, my next question to support: Why aren't childs, part of Record collection? We have HeaderRecords, FooterRecords and Records collection and none of these collections contains the childs of parent records....   
 
I will add this to my list and see what happens...
Thanks
 


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....


Posted By: markmark
Date Posted: 29 November 2010 at 4:03am
Hi Aaron.
 
I hope they add the childs in the next update, would make sense to me.
Interestinly wndReportControl.SelectedRows does include childs, but only if they are expanded
 
 
Mark


-------------
Product: Xtreme SuitePro (ActiveX) version 13.0.0
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0


Posted By: Michael S.
Date Posted: 29 November 2010 at 5:43am

As I understood the ReportControl, the Rows collection always represents the visible rows in the control, with sorting, filtering, etc. applied.

If you want to process all your data in the control, being it visibile or not, you have to process the Records collection including the Childs collection for every record if Childs.Count > 0. Remember, that the records aren't necessarily in the same order as the Rows. (It's a little bit like MVC.)



-------------
Product: Xtreme SuitePro (ActiveX) version 15.1.3
Platform: Windows 7 Prof. SP 1 x64
Language: Visual Basic 6.0



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