Print Page | Close Window

Populate expands child items

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=6818
Printed Date: 22 November 2024 at 1:23pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Populate expands child items
Posted By: rmercer
Subject: Populate expands child items
Date Posted: 09 April 2007 at 10:45am
Is there any way to prevent Populate() from changing the collapsed state of child items in the report control?
 
This behavior can be reproduced in the ReportSample application.
 
1) Right-click on any group item and choose "Collapse All Groups"
2) Expand "From: Bruce Wayne" group.
3) Click on checkbox on the far right of the "Bruce Wayne" item.
 
All groups expand after you click the checkbox.
 
In my application I have many child items and the user expects the collapsed states to be retained upon application restart.  Whenever an item is added, renamed, or deleted Populate() is called.  This causes all child items to expand which is quite annoying to the user.
 
Thank you.



Replies:
Posted By: sserge
Date Posted: 13 April 2007 at 3:31pm
Hi,

This is actually a known problem. Unfortunately it's not easy to solve it in terms of Populate logic, but there is another way (as I see it) -- having methods which will add or remove records on the 'fly' (update rows structure without Populate call).

Methods for such remove on the 'fly' have been already added to version 11.1.0 (which is coming soon):

  CXTPReportControl::RemoveRecordEx
  CXTPReportControl::RemoveRowEx


We plan to add other 'on the fly' method CXTPReportControl::AddRecordEx in the nearest future.

In these terms, task with updating a single record (like changing a checkbox) will look like:

  RemoveRecordEx(pRecord)
 
  //edit record data here
  // ...

  AddRecordEx(pRecord)

  AdjustLayout()


--
Regards,
Sergey 


Posted By: bschaer
Date Posted: 11 August 2007 at 9:57pm
Desperately need the "AddRecordEx" logic you have eluded to.....
 
Much thanks


Posted By: sserge
Date Posted: 14 August 2007 at 5:21pm
Next version will include it.

--
WBR,
Serge


Posted By: bschaer
Date Posted: 15 September 2007 at 12:22pm
The logic you have outlined for updating record data does not work with 11.2.0 because on the RemoveRecordEx call, the record is deleted upon InternalRelease.  So I wrapped the Remove/Add with AddRef/Release (below) and this creates a new problem with the row logic at XTReportRow.cpp line 814 (ASSERT(m_pParentRows->GetAt(m_nChildIndex) == this);
 
When only one record is added/updated, no ASSERT triggered.  On second record added then updated you get it.
 
I need on the fly inserts and updates without using Populate.  The updates need to perform resort/regroup as necessary and I believe you have coded that way.
 
This is a critical situation that I need resolution on soon.  Thanks.
 
For new record:
CMyReportRecord* pNew = new CMyReportRecord();
pRecord->m_pSomeItem->SetValue(SomeInitialValue);
GetReportCtrl().AddRecordEx(pNew);
GetReportCtrl().RedrawControl();
 
For update record:
pRecord->m_pSomeItem->SetValue(SomeNewValue);
pRecord->InternalAddRef();
GetReportCtrl().RemoveRecordEx(pRecord);
GetReportCtrl().AddRecordEx(pRecord);
pRecord->InternalRelease();
 


Posted By: bschaer
Date Posted: 16 September 2007 at 12:37am
Firstly, it seems to me that the AddRecordEx should be doing a InternalAddRef() to balance the InternalRelease done within RemoveRecordEx.  Beyond that, I have not yet worked thru the Row array logic to understand what is leading to the line 814 assert.


Posted By: sserge
Date Posted: 18 September 2007 at 4:50pm
Hi,

Hope adding the following update into the code of RemoveRecordEx in bold will fix the problem:


  ...
  } while (pRow && pRow->IsGroupRow() && pRow->GetChilds()->GetCount() == 0);
 
  // refresh child indices
  if(pRow && pRow->HasChildren())
   pRow->GetChilds()->RefreshChildIndices();
  else
   m_pPlainTree->RefreshChildIndices();
 
  bResult = TRUE;
  ...


--
WBR,
Serge



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