Sort with "no value" content |
Post Reply |
Author | |
Algae
Senior Member Joined: 08 January 2007 Location: United States Status: Offline Points: 217 |
Post Options
Thanks(0)
Posted: 04 January 2010 at 2:35pm |
Q: Is there a mechanism to take into account "no value" items in a numeric sort column?
A: Apparently there's no numeric "no value" mechanism, so here's the modification I used: File: XTPReportRecordItemText.cpp Method: CXTPReportRecordItemNumber::Compare int CXTPReportRecordItemNumber::Compare(CXTPReportColumn*, CXTPReportRecordItem* pItem) { CXTPReportRecordItemNumber* pItemNumber = DYNAMIC_DOWNCAST(CXTPReportRecordItemNumber, pItem); if (!pItemNumber) return 1; // Change to 1 - for sparse sorting // return 0; if (m_dValue == pItemNumber->m_dValue) return 0; else if (m_dValue > pItemNumber->m_dValue) return 1; else return -1; } For example I have a numeric column. If the value is 0, I don't want to show a value, but rather a blank. Of course the columns must be numeric and not strings to sort properly! By default when using a numeric item with a 0 value a value of 0 will display. The obvious solution is to set the item to a default item in the record instead of a numeric item so no value is shown. However, there's where the problem comes in. If you use a non-numeric item sorting is jumbled since a non-numeric "no value" item is considered equal in the compare routine, |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |