Print Page | Close Window

Sort with "no value" content

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=15949
Printed Date: 18 June 2025 at 9:41am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Sort with "no value" content
Posted By: Algae
Subject: Sort with "no value" content
Date 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,






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