Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - Problem with sorting unicode text column
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Problem with sorting unicode text column

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


Joined: 16 January 2004
Location: Germany
Status: Offline
Points: 251
Post Options Post Options   Thanks (0) Thanks(0)   Quote Marco1 Quote  Post ReplyReply Direct Link To This Post Topic: Problem with sorting unicode text column
    Posted: 07 October 2008 at 1:01pm
Hi,
there seems to be a problem in sorting unicode (wide) text in a column.

A column with 500 records is filled with a presorted lastnames out of a database. No problem, sorting of mysql works fine.

If one clicks on the header of the 'lastname'-column, the sorting arrow appears and the column gets resorted by the ReportControl.

The correct order (of lastnames) returned by mysql is:
Tacke
test
Thiele
Ürün         <-- Starts with german "Umlaut"
Volk
Zietlow

The ReportControl sorts like
Tacke
Thiele
Volk
Zietlow
test
Ürün

Small letters are sorted to the end, "Umlaute" (ö,ä,ü) which must be treated as o,a,u are sorted to the end, too.
I haven't investigated further, perhaps anyone have observed/solved a similar problem?

Thanx, Marco

Back to Top
adrien View Drop Down
Senior Member
Senior Member


Joined: 30 April 2007
Location: New Zealand
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote adrien Quote  Post ReplyReply Direct Link To This Post Posted: 09 October 2008 at 12:47am
It's using straight string compare.

I was just going to complain about this too - it should at least be doing case-insensitive sorting.

Looks like there is a func to set sort callback, so you can do your own comparison...

SetRowsCompareFunc


Back to Top
adrien View Drop Down
Senior Member
Senior Member


Joined: 30 April 2007
Location: New Zealand
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote adrien Quote  Post ReplyReply Direct Link To This Post Posted: 09 October 2008 at 12:48am
SetRowsCompareFunc doesn't look to be much use though

since you don't get told which column is being sorted.
Back to Top
adrien View Drop Down
Senior Member
Senior Member


Joined: 30 April 2007
Location: New Zealand
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote adrien Quote  Post ReplyReply Direct Link To This Post Posted: 09 October 2008 at 1:04am
CXTPReportRecordItem::Compare

override this for each item in your records that you want to control sort order on.
Back to Top
adrien View Drop Down
Senior Member
Senior Member


Joined: 30 April 2007
Location: New Zealand
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote adrien Quote  Post ReplyReply Direct Link To This Post Posted: 09 October 2008 at 1:21am
actually this is a pain in the neck.

You would need to subclass for all items.

It would be good if a compare func could be installed into the report control that could be used to compare strings. then this could be used to sort any field type that was a string.

Otherwise you are constantly doing sad things like...

class CXTPReportRecordItemCaseInsensitiveSortText : public CXTPReportRecordItemText
{
public:
virtual int Compare(CXTPReportColumn* pColumn, CXTPReportRecordItem* pItem)
{
    return m_strText.CompareNoCase(pItem->GetCaption(pColumn));
}
};

and using CXTPReportRecordItemCaseInsensitiveSortText wherever you would otherwise use CXTPReportRecordItemText
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.156 seconds.