Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - Sort with "no value" content
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Sort with "no value" content

 Post Reply Post Reply
Author
Message
Algae View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 January 2007
Location: United States
Status: Offline
Points: 217
Post Options Post Options   Thanks (0) Thanks(0)   Quote Algae Quote  Post ReplyReply Direct Link To This Post Topic: Sort with "no value" content
    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,



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.