Columns Expand/Collapse not working |
Post Reply |
Author | |
Sergio
Senior Member Joined: 18 September 2006 Status: Offline Points: 216 |
Post Options
Thanks(1)
Posted: 11 December 2012 at 6:08am |
Hello,
There is a bug in code, columns expand/collapse doesn't work. Your code (Codejock MFC TookKit Pro version 15.2.1): void CXTPReportColumn::SetExpanded(BOOL bExpanded) { m_bExpanded = bExpanded; int nCnt = m_pColumns->GetCount(); int iN = GetNextVisualBlock(); int iVs = GetVisibleIndex(); CXTPReportColumn* pCol = NULL; for (int iC = 0; iC < nCnt; iC++) { pCol = m_pColumns->GetAt(nCnt - iC - 1); if (pCol) { if (bExpanded) { int iVc = pCol->GetVisibleIndex(); if (iVc == -1) continue; if (iN > 0 && iVc > iVs && iVc <= iVs + iN) pCol->SetVisible(FALSE); else if (iN < 0 && iVc < iVs && iVc >= iVs + iN) pCol->SetVisible(FALSE); } else { int iVc = pCol->GetOldVisibleIndex(); if (iVc == -1) continue; if (iN > 0 && iVc > iVs && iVc <= iVs + iN) pCol->SetVisible(TRUE); //else if (iN < 0 && iVc <= iVs + 1 && iVc >= iVs + iN) else if (iN < 0 && iVc <= iVs + 2 && iVc >= iVs + iN) pCol->SetVisible(TRUE); } } } } My fix: int CMyXTPReportColumn::SetExpanded(BOOL bExpanded) { // Fixes a bug in Codejock version 15.2.1 - CXTPReportColumn::SetExpanded(...) m_bExpanded = bExpanded; CXTPReportControl* pControl = GetControl(); if (pControl) { int nNextVisualBlock = GetNextVisualBlock(); if (nNextVisualBlock != 0) { int nItemIndex = GetItemIndex(); int nStart; int nEnd; if (nNextVisualBlock < 0) { nStart = nItemIndex + nNextVisualBlock; nEnd = nItemIndex; } else { nStart = nItemIndex + 1; nEnd = nItemIndex + nNextVisualBlock + 1; } CXTPReportColumn* pColumnExp; for (int i=nItemIndex + nNextVisualBlock; i < nItemIndex; i++) { pColumnExp = pControl->FFindColumn(i); // Find column by internal index instead of position if (pColumnExp) pColumnExp->SetVisible(bExpanded); } } pControl->AdjustLayout(); pControl->AdjustScrollBars(); } } Moreover, beware of initial state of expand/collapse that isn't also correctly set. I let you do that fix by yourself. Regards
|
|
Sergio
|
|
Sergio
Senior Member Joined: 18 September 2006 Status: Offline Points: 216 |
Post Options
Thanks(0)
|
Please note that FFindColumn(...) is our method, it find the column by the item index rather than by the column position.
Doing so, it works also when the columns are moved! Your code doesn't work also when columns aren't moved! Regards
|
|
Sergio
|
|
Sergio
Senior Member Joined: 18 September 2006 Status: Offline Points: 216 |
Post Options
Thanks(0)
|
I've just updated my post with some fixes...
|
|
Sergio
|
|
Algae
Senior Member Joined: 08 January 2007 Location: United States Status: Offline Points: 217 |
Post Options
Thanks(0)
|
Sergio -
Thanks for the fix. It looks cleaner than the CJ material. For V. 16.2.3 I found it unnecessary though. A couple things, relevant to 16.2.3: 1. Shouldn't function be void? 2. pColumnExp = GetColumns()->Find(i); // replace FFind. |
|
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 |