Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Report Control
  New Posts New Posts RSS Feed - Looping through ALL rows
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Looping through ALL rows

 Post Reply Post Reply
Author
Message
markmark View Drop Down
Senior Member
Senior Member


Joined: 30 November 2007
Status: Offline
Points: 142
Post Options Post Options   Thanks (0) Thanks(0)   Quote markmark Quote  Post ReplyReply Direct Link To This Post Topic: Looping through ALL rows
    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
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post 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....
Back to Top
markmark View Drop Down
Senior Member
Senior Member


Joined: 30 November 2007
Status: Offline
Points: 142
Post Options Post Options   Thanks (0) Thanks(0)   Quote markmark Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Aaron View Drop Down
Senior Member
Senior Member
Avatar

Joined: 29 January 2008
Status: Offline
Points: 2192
Post Options Post Options   Thanks (0) Thanks(0)   Quote Aaron Quote  Post ReplyReply Direct Link To This Post 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....
Back to Top
markmark View Drop Down
Senior Member
Senior Member


Joined: 30 November 2007
Status: Offline
Points: 142
Post Options Post Options   Thanks (0) Thanks(0)   Quote markmark Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Michael S. View Drop Down
Newbie
Newbie


Joined: 06 October 2009
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote Michael S. Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.125 seconds.