Print Page | Close Window

Adding a row to a collapsed CXTPReportControl

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=16689
Printed Date: 03 May 2024 at 8:12pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Adding a row to a collapsed CXTPReportControl
Posted By: acwest
Subject: Adding a row to a collapsed CXTPReportControl
Date Posted: 10 May 2010 at 5:15pm
In our application, we have a CXTPReportControl containing a potentially large number of rows. The problem I am having is that it appears that when a row is added into the tree, if the user has collapsed the tree, it gets expanded automatically. I would like to prevent this from happening. I put some breakpoints in the code, and CXTPReportRow::SetExpanded does not appear to be called...
-Craig



Replies:
Posted By: acwest
Date Posted: 14 May 2010 at 4:59pm
So does anybody have any ideas on why my control is being expanded? Does anybody else have the same behavior?


Posted By: Aaron
Date Posted: 25 May 2010 at 3:25pm
Hi,
 
I am using ActiveX but I think it has same problem... Call Populate automatically expands all collapsed rows.
 
 
And to all other MFC users, why don't you reply on this? Only nagging about bugs/problems isn't what a forum is about, helping your fellow users thats what's a forum is for !!!!
 
 
 


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....


Posted By: acwest
Date Posted: 03 November 2010 at 4:25pm
I have just updated my project to use the latest version of the toolkit (13.4.2) and still see the same behaviour. Is there any way to have collapsed rows NOT expand? 


Posted By: Sneemaster
Date Posted: 29 November 2010 at 12:32pm
I am also noticing the same problem. Are there any updates on this? Can we force-collapse the rows after we run the Populate command? If so, how do we determine if the rows were originally collapsed?


Posted By: acwest
Date Posted: 17 May 2011 at 4:32pm
My solution, if you can call it that, was to subclass the report control, and in my populate, get a list of all collapsed rows, then recollapse them, unless they contained new records, in which case, leave them expanded
CSubclassReportControl
{
...
    std::list<CXTPReportRecord*> m_NewRecords;
    CXTPReportRecord* AddRecord(CXTPReportRecord* pRecord)
    {
        POSITION pos = m_NewRecords.Find(pRecord);
        if (!pos)
            m_NewRecords.AddTail(pRecord);
        return __super::AddRecord(pRecord);
    }
  
    void Populate()
    {
        CList<CString> collapsedRows;
        CXTPReportRows *pRows = GetRows();
        for (int i = 0; i < pRows->GetCount(); i++)
        {
            CXTPReportRow *pRow = pRows->GetAt(i);
            if (pRow && pRow->IsGroupRow() && !pRow->IsExpanded())
            {
                CXTPReportGroupRow* pGroupRow = (CXTPReportGroupRow*) pRow;
                collapsedRows.AddTail(pGroupRow->GetCaption());
            }
        }
        __super::Populate();
        pRows = GetRows();
        for (int i = 0; i < pRows->GetCount(); i++)
        {
            CXTPReportRow *pRow = pRows->GetAt(i);
            if (pRow && pRow->IsGroupRow())
            {
                CXTPReportGroupRow* pGroupRow = (CXTPReportGroupRow*) pRow;
                CString caption = pGroupRow->GetCaption();
                POSITION pos = collapsedRows.Find(caption);
                if (pos)
                {
                    bool foundNew = false;
                    CXTPReportRows *pChilds = pRow->GetChilds();
                    for (int j = 0; j < pChilds->GetCount(); j++)
                    {
                        CXTPReportRow *pChild = pChilds->GetAt(j);
                        if (pChild)
                        {
                            CXTPReportRecord* pRecord = pChild->GetRecord();
                            POSITION pos = m_NewRecords.Find(pRecord);
                            if (pos)
                            {
                                m_NewRecords.RemoveAt(pos);
                                foundNew = true;
                                break;
                            }
                        }
                    }
                    if (!foundNew)
                    {
                        pGroupRow->SetExpanded(FALSE);
                    }
                    collapsedRows.RemoveAt(pos);
                }
            }
        }
        m_NewRecords.RemoveAll();
    }
};


Posted By: ABuenger
Date Posted: 19 May 2011 at 9:10am
Hi,

currently Populate() does not keep the current expand state. All rows are destroyed and the recreated. I look into a solution for the next release.

Andre



-------------
Codejock support



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