Print Page | Close Window

Sorting in ReportControl

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=8741
Printed Date: 11 May 2024 at 1:16am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Sorting in ReportControl
Posted By: myddyn
Subject: Sorting in ReportControl
Date Posted: 09 November 2007 at 5:23pm
I recently turned on sort for child by using SetSortRecordChilds(TRUE);
 
and now get an ASSERT in the follow function.
 
CXTPReportRow* CXTPReportRow::GetNextSiblingRow() const

{

if (!m_pParentRows)

return 0;

if (m_nChildIndex == -1)

return 0;

ASSERT(m_pParentRows->GetAt(m_nChildIndex) == this);

if (m_nChildIndex < m_pParentRows->GetCount() - 1)

return m_pParentRows->GetAt(m_nChildIndex + 1);

return 0;

}
After doing a little debug, it seem that the record it is getting the
itself because the record has moved but the index is the same.  If I ignore all the ASSERT the program and sort execute correctly.  If I take out the code that moves the children around it works correctly.


-------------
It's horrible to see a family ripped apart by some as simple as.... wild dogs.



Replies:
Posted By: Sergio
Date Posted: 13 February 2008 at 6:07am
Hi,
 
We have the same problem.
 
It seems to be linked to the sorted column.
 
This error comes when you add a child record, with the SetSortRecordChilds(TRUE) activated, and with one or more columns sorted.
 
If no column is sorted, the problem doesn't occur.
 
We think that's a bug of the Report Control.
 
Regards,


-------------
Sergio


Posted By: Sergio
Date Posted: 11 March 2008 at 7:07am
Hi,
 
In fact, there's really a bug in Release mode :
 
Hope to get an answer now...
 


-------------
Sergio


Posted By: Sergio
Date Posted: 16 April 2008 at 8:14am

While looking inside using the debugger, it seems that there's a confusion between these Rows arrays :

  - CXTPReportRows* m_pPlainTree

  - CXTPReportRows* m_pRows
 
 They both hold pointers to the same object, but the CXTPReportRow class can hold only one parent Rows.
 
I have tried to force the refresh of indexes, using a class overriden from the CXTPReportControl one :
 
void CMyXTPReportControl::RefreshDisplay()
{
     m_bRefreshIndexes = TRUE;
     Populate();
 
     m_pHeaderRows->RefreshChildIndices(TRUE);
     m_pRows->RefreshChildIndices(TRUE);
     m_pFooterRows->RefreshChildIndices(TRUE);
 
     m_pPlainTree->RefreshChildIndices(TRUE);
 
     m_arrScreenRows.RefreshChildIndices(TRUE);
}
 
void CMyXTPReportControl::RefreshSort()
{
     m_bRefreshIndexes = TRUE;
     ReSortRows();
 
     m_pHeaderRows->RefreshChildIndices(TRUE);
     m_pRows->RefreshChildIndices(TRUE);
     m_pFooterRows->RefreshChildIndices(TRUE);
 
     m_pPlainTree->RefreshChildIndices(TRUE);
 
     m_arrScreenRows.RefreshChildIndices(TRUE);
}
But it just moved the problem...
 
H E L P !


-------------
Sergio


Posted By: Sergio
Date Posted: 16 June 2008 at 10:10am
Hi,
 
Any news ?


-------------
Sergio


Posted By: Sergio
Date Posted: 02 July 2008 at 12:10pm
Hi,
 
I have just downloaded and checked this issue with the MFC Codejock Release 12.0.0.
 
There is still the same problem.
 
Have you been able to reproduce this problem ?


-------------
Sergio


Posted By: Sergio
Date Posted: 09 July 2008 at 4:16am

Hi,

Now, I know more about this issue.
 
This problem doesn't occur if you clear the sort before modifying records.
 
Here is my code :
============
 
////////////////////////////////////////////////////
// Clear sort
////////////////////////////////////////////////////
int nTopRow = m_pRP->GetTopRowIndex(); // store the first displayed row index
CXTPReportColumnOrder* pSortOrder = m_pRP->GetColumns()->GetSortOrder();
CArray<CXTPReportColumn*, CXTPReportColumn*> aReportColumns;
CArray<BOOL, BOOL> aSortAscending;
for (int i=0; i<pSortOrder->GetCount(); i++)
{
     aReportColumns.Add(pSortOrder->GetAt(i));
     aSortAscending.Add(pSortOrder->GetAt(i)->IsSortedIncreasing());
}
m_pRP->FClearSort();
 
////////////////////////////////////////////////////
// ...
// Modify records and child records
// ...
////////////////////////////////////////////////////
 
////////////////////////////////////////////////////
// Restore sort
////////////////////////////////////////////////////
for (int i=0; i<aReportColumns.GetSize(); i++)
{
     m_pRP->GetColumns()->InsertSortColumn(aReportColumns.GetAt(i));
     aReportColumns.GetAt(i)->SetSortIncreasing(aSortAscending.GetAt(i));
}
m_pRP->FRefreshSort();
m_pRP->SetTopRow(nTopRow); // Restore the index of the first displayed row of the report


-------------
Sergio


Posted By: zitz
Date Posted: 05 October 2008 at 7:24am
Hi, Serqio.
I solve this problem by calling ReSortRows() after Populate()
(Xtreme ToolkitPro v11.2.0)

void CReportControlEx::Populate()
{
 CXTPReportControl::Populate();
 ReSortRows();
}


Posted By: Sergio
Date Posted: 13 May 2009 at 9:29am
Hi Zitz,

I just read your answer, sorry for the long delay.

Yes, I confirm that ReSortRows() works and fix the problem. (We did the same.)

Thank you for your answer.

Regards,

-------------
Sergio



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