Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - Report Group Expand state bug
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Report Group Expand state bug

 Post Reply Post Reply
Author
Message
Algae View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 January 2007
Location: United States
Status: Offline
Points: 217
Post Options Post Options   Thanks (0) Thanks(0)   Quote Algae Quote  Post ReplyReply Direct Link To This Post Topic: Report Group Expand state bug
    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?
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 28 August 2009 at 12:09am
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
Back to Top
Algae View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 January 2007
Location: United States
Status: Offline
Points: 217
Post Options Post Options   Thanks (0) Thanks(0)   Quote Algae Quote  Post ReplyReply Direct Link To This Post Posted: 28 August 2009 at 3:53pm
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());
    }
}




Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 28 August 2009 at 4:31pm
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
Back to Top
Algae View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 January 2007
Location: United States
Status: Offline
Points: 217
Post Options Post Options   Thanks (0) Thanks(0)   Quote Algae Quote  Post ReplyReply Direct Link To This Post Posted: 29 August 2009 at 3:47pm
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.
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 29 August 2009 at 4:27pm
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. 
Back to Top
Algae View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 January 2007
Location: United States
Status: Offline
Points: 217
Post Options Post Options   Thanks (0) Thanks(0)   Quote Algae Quote  Post ReplyReply Direct Link To This Post Posted: 30 August 2009 at 4:36pm
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.
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 30 August 2009 at 5:07pm
Back to Top
Algae View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 January 2007
Location: United States
Status: Offline
Points: 217
Post Options Post Options   Thanks (0) Thanks(0)   Quote Algae Quote  Post ReplyReply Direct Link To This Post Posted: 31 August 2009 at 9:22pm
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. 
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 31 August 2009 at 9:32pm
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)
Back to Top
Algae View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 January 2007
Location: United States
Status: Offline
Points: 217
Post Options Post Options   Thanks (0) Thanks(0)   Quote Algae Quote  Post ReplyReply Direct Link To This Post Posted: 02 September 2009 at 3:14pm
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?
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.125 seconds.