Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - Sorting bug if GetGroupCaption overridden
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Sorting bug if GetGroupCaption overridden

 Post Reply Post Reply
Author
Message
Warren View Drop Down
Groupie
Groupie
Avatar

Joined: 23 February 2005
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote Warren Quote  Post ReplyReply Direct Link To This Post Topic: Sorting bug if GetGroupCaption overridden
    Posted: 16 September 2005 at 2:48pm
I just spent a fair bit of time tracking this down, so Id 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 Im 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.


Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down



This page was generated in 0.094 seconds.