Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - Sorting in ReportControl
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Sorting in ReportControl

 Post Reply Post Reply
Author
Message
myddyn View Drop Down
Newbie
Newbie
Avatar

Joined: 07 May 2004
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote myddyn Quote  Post ReplyReply Direct Link To This Post Topic: Sorting in ReportControl
    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.
Back to Top
Sergio View Drop Down
Senior Member
Senior Member
Avatar

Joined: 18 September 2006
Status: Offline
Points: 216
Post Options Post Options   Thanks (0) Thanks(0)   Quote Sergio Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Sergio View Drop Down
Senior Member
Senior Member
Avatar

Joined: 18 September 2006
Status: Offline
Points: 216
Post Options Post Options   Thanks (0) Thanks(0)   Quote Sergio Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Sergio View Drop Down
Senior Member
Senior Member
Avatar

Joined: 18 September 2006
Status: Offline
Points: 216
Post Options Post Options   Thanks (0) Thanks(0)   Quote Sergio Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Sergio View Drop Down
Senior Member
Senior Member
Avatar

Joined: 18 September 2006
Status: Offline
Points: 216
Post Options Post Options   Thanks (0) Thanks(0)   Quote Sergio Quote  Post ReplyReply Direct Link To This Post Posted: 16 June 2008 at 10:10am
Hi,
 
Any news ?
Sergio
Back to Top
Sergio View Drop Down
Senior Member
Senior Member
Avatar

Joined: 18 September 2006
Status: Offline
Points: 216
Post Options Post Options   Thanks (0) Thanks(0)   Quote Sergio Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Sergio View Drop Down
Senior Member
Senior Member
Avatar

Joined: 18 September 2006
Status: Offline
Points: 216
Post Options Post Options   Thanks (0) Thanks(0)   Quote Sergio Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
zitz View Drop Down
Senior Member
Senior Member


Joined: 05 October 2008
Status: Offline
Points: 112
Post Options Post Options   Thanks (0) Thanks(0)   Quote zitz Quote  Post ReplyReply Direct Link To This Post 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();
}
Back to Top
Sergio View Drop Down
Senior Member
Senior Member
Avatar

Joined: 18 September 2006
Status: Offline
Points: 216
Post Options Post Options   Thanks (0) Thanks(0)   Quote Sergio Quote  Post ReplyReply Direct Link To This Post 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
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.172 seconds.