Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - Populate expands child items
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Populate expands child items

 Post Reply Post Reply
Author
Message
rmercer View Drop Down
Groupie
Groupie


Joined: 22 February 2006
Status: Offline
Points: 34
Post Options Post Options   Thanks (0) Thanks(0)   Quote rmercer Quote  Post ReplyReply Direct Link To This Post Topic: Populate expands child items
    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.
Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post 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 
Back to Top
bschaer View Drop Down
Groupie
Groupie


Joined: 27 June 2006
Location: United States
Status: Offline
Points: 28
Post Options Post Options   Thanks (0) Thanks(0)   Quote bschaer Quote  Post ReplyReply Direct Link To This Post Posted: 11 August 2007 at 9:57pm
Desperately need the "AddRecordEx" logic you have eluded to.....
 
Much thanks
Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post Posted: 14 August 2007 at 5:21pm
Next version will include it.

--
WBR,
Serge
Back to Top
bschaer View Drop Down
Groupie
Groupie


Joined: 27 June 2006
Location: United States
Status: Offline
Points: 28
Post Options Post Options   Thanks (0) Thanks(0)   Quote bschaer Quote  Post ReplyReply Direct Link To This Post 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();
 
Back to Top
bschaer View Drop Down
Groupie
Groupie


Joined: 27 June 2006
Location: United States
Status: Offline
Points: 28
Post Options Post Options   Thanks (0) Thanks(0)   Quote bschaer Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post 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
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.109 seconds.