Print Page | Close Window

Progress Column Sort

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=19717
Printed Date: 15 May 2024 at 5:03pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Progress Column Sort
Posted By: dalai
Subject: Progress Column Sort
Date Posted: 07 May 2012 at 5:09pm
added progress column in CXTPReportControl but not sorted correctly?



Replies:
Posted By: jpbro
Date Posted: 08 May 2012 at 11:37am
What's you XAML/Markup for the progress bar? Can you make a small sample that I can experiment with?

-------------
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6



Posted By: dalai
Date Posted: 09 May 2012 at 5:06am

ok thanks, not using XAML (maybe this is the problem?) just using the CXTPReportRecordItemProgress class as defined in the ReportCustomDraw sample

CXTPReportRecordItemProgress* pRIP;
cstr.Format(_T("%d%%"), progress, 0);
pRIP = new CXTPReportRecordItemProgress(cstr, RGB(130, 192, 255), 12, 3, 1, 100, 1, progress);
AddItem(pRIP);



Posted By: dalai
Date Posted: 09 May 2012 at 12:09pm
ReportCustomDraw sample appears to sort ok so I'm obvioulsy missing something?


Posted By: dalai
Date Posted: 09 May 2012 at 12:39pm
project uploaded ...
uploads/6562/ReportTest.zip -
uploads/6562/ReportTest.zip


Posted By: dalai
Date Posted: 11 May 2012 at 8:28am
probably doing something silly but something weird is happening ...
if I use 9,8,7,6 then sort order is 9,8 & 7,6 + 8,9 & 6,7 (which is ok)
 
if I use 100,75,50,5 then sort order is 75,100 & 50,5 + 100,75 & 5,50
 


Posted By: DazMan
Date Posted: 11 May 2012 at 11:57am
Think you will find the column is being sorted alphabetically, there are two possible solutions
 
Quick and dirty...
 
Change the format specifier of the caption, to include preceding spaces, as per the following line:
 
    cstr.Format(_T("%3d%%"), progress, 0);
 
 
Or the more elegant...
 
Override the virutal Compare function definined in the base class of your CXTPReportRecordItemProgress class to sort the rows based on the m_nProgressPos member variable, causing the compare to be made numerically.  Code would look something like this:
 
int CXTPReportRecordItemProgress::Compare(CXTPReportColumn*, CXTPReportRecordItem* pItem)
{
    CXTPReportRecordItemProgress* pItemProgress = DYNAMIC_DOWNCAST(CXTPReportRecordItemProgress, pItem);
    if (!pItemProgress)
        return 0;
    if (m_nProgressPos == pItemProgress->m_nProgressPos)
        return 0; 
    if (m_nProgressPos > pItemProgress->m_nProgressPos)
        return 1;
    return -1;
}


Posted By: dalai
Date Posted: 12 May 2012 at 7:43am
thanks. cstr.Format(_T("%3d%%"), progress, 0); fixed it.



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