Print Page | Close Window

Sorting bug if GetGroupCaption overridden

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=2907
Printed Date: 04 December 2024 at 3:22am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Sorting bug if GetGroupCaption overridden
Posted By: Warren
Subject: Sorting bug if GetGroupCaption overridden
Date Posted: 16 September 2005 at 2:48pm
I just spent a fair bit of time tracking this down, so I’d like to let everyone know about it, and hopefully someone from Codejock can comment on it too.

If you override GetGroupCaption (e.g. to return “2003” for all dates in the year 2003 for a date) this will cause the sorting to be incorrect when you group by more than one column. (where the column with the overridden GetGroupCaption is the primary group).

 this is because the last line of the function:

CXTPReportRecordItem::CompareGroupCaption

is:

return Compare(pColumn, pItem);

 
This goes in and compares the actual data values, ignoring the overridden caption text.

 The fix is to override CompareGroupCaption, and write:

return GetGroupCaption(pColumn).Collate( pItem->GetGroupCaption(pColumn) );

 
This compare the captions (from the overridden GetGroupCaption), rather than the actual data values.

I would suggest that the last line of CXTPReportRecordItem::CompareGroupCaption

be changed from:

return Compare(pColumn, pItem);

to

return GetGroupCaption(pColumn).Collate( pItem->GetGroupCaption(pColumn)

Hopefully, what I’m suggesting is correct - can someone from Codejock please comment on this.

Thanks

Warren

...or failing that, there should be a HUGE warning comment in the functions telling you that you MUST override CompareGroupCaption if you override GetGroupCaption.





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