Report Group Expand state bug |
Post Reply |
Author | |
Algae
Senior Member Joined: 08 January 2007 Location: United States Status: Offline Points: 217 |
Post Options
Thanks(0)
Posted: 23 August 2009 at 10:58pm |
Version 13.1 VS 2008
Either the logic escapes me or this is a bug. I am attempting to toggle expanded and collapsed state of selected rows. Try #1. I first tried setting the state variable of the selected row(s). It DOES change, but nothing happens on screen because none of them were the special "group" rows. POSITION pos = pSelectedRows->GetFirstSelectedRowPosition(); while (pos) { pRow = pSelectedRows->GetNextSelectedRow(pos); pRow->SetExpanded(!pRow->IsExpanded()); } Next I tried setting the state of the selected Group row(s). Nothing happens on screen. Again because none of the selection rows are special "group" rows. Yes, even tried "populate". All that did was made it really slow POSITION pos = pSelectedRows->GetFirstSelectedRowPosition(); while (pos) { pRow = pSelectedRows->GetNextSelectedRow(pos); if (pRow->IsGroupRow()) { pRow->SetExpanded(!pRow->IsExpanded()); } } Next, I tried getting the parent of the selected row(s) to obtain the special group row but they are not in the selected row list even if they have a little checkbox saying so. However, the parent IS counted in the selected rows array and gleefully crashes my code when "pos" goes out of range! CXTPReportSelectedRows* pSelectedRows = GetReportCtrl().GetSelectedRows(); if (!pSelectedRows) return; CXTPReportRow* pRow = NULL; CXTPReportRow* pParent = NULL; POSITION pos = pSelectedRows->GetFirstSelectedRowPosition(); while (pos) { pRow = pSelectedRows->GetNextSelectedRow(pos); if (pRow) { pParent = pRow->GetParentRow(); if (pParent) pParent->SetExpanded(!pParent->IsExpanded()); } } I think that either 1. the group rows should be included in the selected row list so you don't have to fish for the parents. or 2. The parent should NOT be included in the selection row list nor in the selected row array or 3. parent should not be in selected row array if they aren't "checked". As a final note, I seem to recall this worked at one time. Am I missing something obvious here or there needs to be some CJ library repair? |
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
Please get recent source and make build to check this effect - https://forum.codejock.com/uploads/DemoVersion/ReportControlMFCUpdatedAug27.rar
Btw - new flag ReportControl.m_bSelectionExcludeGroupRows (default = FALSE - 12.1 version behaviour)
allow to hightlite or not group rows in selection - see https://forum.codejock.com/uploads/DemoVersion/ReportSampleStatic.rar with default settings
Group Row in most case - visual artefacts (no record behind). Selection operate with set of records. Feel difference
|
|
Algae
Senior Member Joined: 08 January 2007 Location: United States Status: Offline Points: 217 |
Post Options
Thanks(0)
|
The first thing I noticed was the group row was now selectable and had no checkbox. Maybe I'm confused as to the intent of the checkbox, but I was under the impression that the checkbox was used to indicate selection if the group row was "not" selectable (not highlighted).
With default in constructor: XTPReportControl.cpp CXTPReportControl::CXTPReportControl() m_bSelectionExcludeGroupRows = TRUE; Shouldn't m_bSelectionExcludeGroupRows = TRUE if the group rows are to be excluded from selection? I know it's just semantics, but logically it should be FALSE if group rows are allowed selectable. in XTPReportControl.h BOOL m_bSelectionExcludeGroupRows; // TRUE if selection include group rows - eh? The next thing noticed was that selections do not persist. Here is the effect illustrated: Before Expand: After Expand: As you can see, selection highlight is removed except for the first item group row. I would expect the parent group rows and children to now be selected OR if group rows not selectable, only the child items should be selected. Here is the code that I use to control the expand/collapse. The intent is to toggle expand/collapse on the selected rows regardless of whether they are group rows or child rows. void CReportView::OnExpand() { CXTPReportSelectedRows* pSelectedRows = GetReportCtrl().GetSelectedRows(); if (!pSelectedRows) return; CXTPReportRow* pRow = NULL; CXTPReportRow* pParent = NULL; int nCount = pSelectedRows->GetCount(); for (int i = nCount - 1; i >= 0; i--) { pRow = pSelectedRows->GetAt(i); pParent = pRow->GetParentRow(); if (pParent && pParent->IsGroupRow()) pParent->SetExpanded(!pParent->IsExpanded()); else if (pRow->IsGroupRow()) pRow->SetExpanded(!pRow->IsExpanded()); } } |
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
Please try again with refreshed https://forum.codejock.com/uploads/DemoVersion/ReportSampleStatic.rar based on SVN code (not on Aug 27 working atteampts) - it deal with selection with group rows well
|
|
Algae
Senior Member Joined: 08 January 2007 Location: United States Status: Offline Points: 217 |
Post Options
Thanks(0)
|
The report sample works as expected however there is no mechanism included to illustrate the problem.
The sample uses the same "collapse all" or "expand all" methods which work fine. In addition it allows a single selected row to expand or collapse. This also works fine. The problem is in using multiple selection. There is no control to perform a multiple selection expand/collapse toggle as I've implemented so the process cannot be tested. |
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
Did you try to make deep childs selection and after collapse and expand again parent group row or grand parent... group row?
If you keep Control pressed - Selected childs non-touched, if not - childs unselected. Need to fix this case.
|
|
Algae
Senior Member Joined: 08 January 2007 Location: United States Status: Offline Points: 217 |
Post Options
Thanks(0)
|
If I understand your meaning, the control does indeed work properly if you +/- each row individually while holding ctrl. The selections are retained as they should be. This also works properly using the original 13.1 source.
The difference of course is that when expand/collapse is done programmatically the child selections are not retained. I also attempted using SelectChilds() of the parent after expand/collapse, but it didn't work for me. I hope this helps pinpoint the issue. |
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
Please compare this:
I do have 12.1 sample -
and 13.1 (June) sample -
|
|
Algae
Senior Member Joined: 08 January 2007 Location: United States Status: Offline Points: 217 |
Post Options
Thanks(0)
|
I'm sorry, we must not be communicating. I compared the samples you provided and could not do multiple-select collapse or expand with them. They appeared to have the same functionality.
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
I give a links for old samples to proof another position - they all loose child selection - even you click with Control pressed - now selection kept in such case - this is where I disagree with your comment: >>This also works properly using the original 13.1 source.
(I take original as June version - not later upgrades) |
|
Algae
Senior Member Joined: 08 January 2007 Location: United States Status: Offline Points: 217 |
Post Options
Thanks(0)
|
Thank you for the explanation. I was confused when the samples appeared to perform the same function. I understand now that there has never been child selection retention.
My question is then, is there a way to retain the child selection? SelectChilds() doesn't seem to work with my scenario as I noted before. Given the CXTPReportRow shouldn't SelectChilds() highlight the children as selected? |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |