Print Page | Close Window

Problem with sorting unicode text column

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=12361
Printed Date: 28 March 2024 at 2:03pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Problem with sorting unicode text column
Posted By: Marco1
Subject: Problem with sorting unicode text column
Date 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




Replies:
Posted By: adrien
Date 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




-------------
http://www.wingate.com - http://www.wingate.com


Posted By: adrien
Date 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.

-------------
http://www.wingate.com - http://www.wingate.com


Posted By: adrien
Date 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.

-------------
http://www.wingate.com - http://www.wingate.com


Posted By: adrien
Date 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

-------------
http://www.wingate.com - http://www.wingate.com



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