Report control ExpandAll is not working |
Post Reply |
Author | ||
dennisV
Senior Member Joined: 07 October 2004 Location: Australia Status: Offline Points: 242 |
Post Options
Thanks(0)
Posted: 18 February 2009 at 3:50pm |
|
Hello,
It seems that ExpandAll() in report control only expands the first level in the tree, but not the rest. Also, is it possible to somehow go through all the rows and their children without actually expanding them first? I could use GetChilds(), but maybe there's a non-recursive way to access a flat row list? Thanks, Dennis |
||
// W7 64 Ultimate SP1
// VS 2008 // CodeJock 16.2.3 (MFC) |
||
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
|
Can't confirm - Looks like it works properly.
Check ReportSample - PropertesTest and modify function -
int CPropertiesView::OnCreate(LPCREATESTRUCT lpCreateStruct){ ..............m_wndReport.ExpandAll(); return 0;} |
||
dennisV
Senior Member Joined: 07 October 2004 Location: Australia Status: Offline Points: 242 |
Post Options
Thanks(0)
|
|
Ok, I wasn't counting the "root" level as one, so in reality it means that only the root and first level are expanded.
In the PropertiesTest, add the following near the end of the OnCreate() CXTPReportRecord* pRecordSecondLevel = pRecordPaintManager->GetChilds()->Add( new CRecordPropertyBool(ID_PROPERTY_FLATHEADER, _T("Flat Header"), pTargetReport->GetPaintManager()->GetColumnStyle() == xtpReportColumnFlat)); pRecordSecondLevel->GetChilds()->Add( new CRecordPropertyBool(ID_PROPERTY_HIDESELECTION, _T("Hide Selection"), pTargetReport->GetPaintManager()->m_bHideSelection)); pRecordSecondLevel->GetChilds()->Add( new CRecordPropertyInt(ID_PROPERTY_TREEINDENT, _T("Tree Indent"), pTargetReport->GetPaintManager()->m_nTreeIndent)); and then do ExpandAll() - you'll see that "Flat Header" is not expanded. |
||
// W7 64 Ultimate SP1
// VS 2008 // CodeJock 16.2.3 (MFC) |
||
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
|
You right. There is no traverse across all tree - only care abour 2 levels - parent and childs.
Question - do we need here proper functionality or this is just catch a bug but no business model beside?
|
||
dennisV
Senior Member Joined: 07 October 2004 Location: Australia Status: Offline Points: 242 |
Post Options
Thanks(0)
|
|
Personally, when I see "ExpandAll" I expect exactly that :) Since I need this functionality quite urgently (within a week), I'll write a function to do this myself, but I think it would be good if CJ had that working. Maybe with a ExpandAll(bool bReallyExpandAll = false) sort of way ;)
Also, it would be great if filtering worked on all levels, even if they are not expanded (that's the primary reason I need the ExpandAll - so that when someone tries to search for something, I'll have to expand all entries, otherwise they won't be traversed for searching/filtering). |
||
// W7 64 Ultimate SP1
// VS 2008 // CodeJock 16.2.3 (MFC) |
||
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
|
this version of ExpandAll covered your case properly - now we need to extend it to common case (using recursive function or while(...) loop...)
void CXTPReportControl::ExpandAll(){ BeginUpdate(); for (int i = m_pRows->GetCount() - 1; i >= 0; i--){ CXTPReportRow* pRow = m_pRows->GetAt(i); if (pRow)pRow->SetExpanded(TRUE); } EndUpdate(); EnsureVisible(GetFocusedRow()); BeginUpdate(); for (int i = m_pRows->GetCount() - 1; i >= 0; i--){ CXTPReportRow* pRow = m_pRows->GetAt(i); if (pRow){ CXTPReportRows* pChildRows = pRow->GetChilds(); if (pChildRows){ for (int j = pChildRows->GetCount() - 1; j >= 0; j--){ CXTPReportRow* pChildRow = pChildRows->GetAt(j); if (pChildRow){ pChildRow->SetExpanded(TRUE); } } } } } EndUpdate(); EnsureVisible(GetFocusedRow()); } |
||
dennisV
Senior Member Joined: 07 October 2004 Location: Australia Status: Offline Points: 242 |
Post Options
Thanks(0)
|
|
Thank you - I've created my own version of the Expand All, but I'll try yours as well. Do you think it'll make it into the next update?
|
||
// W7 64 Ultimate SP1
// VS 2008 // CodeJock 16.2.3 (MFC) |
||
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
|
You can try to test https://forum.codejock.com/uploads/DemoVersion/ReportSampleSatic.rar
where Properties form have right button click handler to add childs to row where you click. There are two button on top "A" and "a".
"A" doing recursive ExpandAll, "a" - non-recursive. Adding new childs to this resizable form you can construct very complicated tree structure and after test ExpandAll in my code and also using your one - are you supported any number of tree structure levels?
|
||
dennisV
Senior Member Joined: 07 October 2004 Location: Australia Status: Offline Points: 242 |
Post Options
Thanks(0)
|
|
Strange, I wasn't notified of your reply, so I didn't see it till today...
I'll try the sample a bit later, I've got things working at the moment, but not very efficiently and filtering still doesn't work on collapsed items. In the program, the tree structure is unlimited. Thanks! |
||
// W7 64 Ultimate SP1
// VS 2008 // CodeJock 16.2.3 (MFC) |
||
apautrot
Groupie Joined: 16 April 2009 Location: France Status: Offline Points: 18 |
Post Options
Thanks(0)
|
|
I tried the new ExpandAll method you gave here as a replacement, but I have a buggy behaviour with it. I did my own ExpandRows which works like this :
void ExpandRows ( CXTPReportRows* pRows ) { // for each row unsigned int uiRowCount = pRows -> GetCount(); for ( unsigned int ui = 0; ui < uiRowCount; ui++ ) { // get CXTPReportRow* pRow = pRows -> GetAt ( ui ); // expand if ( ! pRow -> IsExpanded() ) { pRow -> SetExpanded( TRUE ); } // process recursively ExpandRows ( pRow -> GetChilds() ); } } But this give me half my tree expanded. If I execute this method twice, I have more nodes expanded. The more I execute the method, the more expanding I get. I suspect the CXTPReportControl::_DoExpand method to be buggy, something to be linked with an item count or something like that. It is like the more rows we have in the report, the more expand actions are done, like if having 10 visible rows in report will allow less expand done than having 20 rows visible in report. Did you get it ? I hope you will quicly find the problem and offer a solution, it is blocking for me and I sadly need to resolve this issue. EDIT : using your function I even have an assertion ASSERT(pRow->m_bVisible) in the method CXTPReportControl::RefreshIndexes. The rows are displayed in a buggy order, child rows being displayed at wrong index. Please fix it as quickly as possible as it is really really blocking for our software release. EDIT : here is a way to reproduce it, simply create a tree like this (letters are order of creation of records, I don't know if it counts): A C D E B Populate, display control and try to expand with the mouse all the nodes, you might have this : E A C D E B Clicking on expand plus will make it asserts. I'm using version 12.0.0 Thank you. Alexis. |
||
Win 7 x64 VS 2008 CJ 15.13 |
||
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
|
Don't use your own function if there is core function which now doing the job.
If you want to expand all items in full tree - you should start from the top.
If you need fresh source - open issue and if if have valid license for 2009 - I will attach you fresh source or ActiveX - depends of your purchase.
I am not going to fix smth in old version - this is obvious not logical - we are moving only forward - not back!
|
||
dennisV
Senior Member Joined: 07 October 2004 Location: Australia Status: Offline Points: 242 |
Post Options
Thanks(0)
|
|
Ok, the sample seems to work ok - is it using the code snippet above or something else? |
||
// W7 64 Ultimate SP1
// VS 2008 // CodeJock 16.2.3 (MFC) |
||
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
|
Of course not - this snippet is some client code (may be even for special case!?) - but in the sample you are running my code - a part of current source
|
||
dennisV
Senior Member Joined: 07 October 2004 Location: Australia Status: Offline Points: 242 |
Post Options
Thanks(0)
|
|
Ok, so I assume it'll work in the next update then, right? I can live with what I have written myself for the time being, till CJ is updated and I can use internal functionality better. |
||
// W7 64 Ultimate SP1
// VS 2008 // CodeJock 16.2.3 (MFC) |
||
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
|
Sure - up to you - if you want pre-release to use - you can. I published the exe-sample to give people try on any tree stucture they can make
|
||
apautrot
Groupie Joined: 16 April 2009 Location: France Status: Offline Points: 18 |
Post Options
Thanks(0)
|
|
I tried to use my own function because the function ExpandAll is the version 12.0.0 have bugs. I 'm obvisouly not pleased to reinvent the wheel and loose my time trying to fix 3rd party code.
I guess my office have no other choice than buying the latest upgrade. |
||
Win 7 x64 VS 2008 CJ 15.13 |
||
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
|
It make sense as there are now a lot of new features, fixes, support and so on...
|
||
apautrot
Groupie Joined: 16 April 2009 Location: France Status: Offline Points: 18 |
Post Options
Thanks(0)
|
|
My office bought the latest version (13.0.0) and I still have the same bug with the ExpandAll function code you provided above in this thread.
The ExpandAll provided with the 13.0.0 obviously do not work properly, code provided here has a bug, but my ExpandRows function that I provided above now do the job, use it by doing ExpandRows ( pReportControl->GetRows() ) and voila. So I will use my own function rather than your core function that do not do the job. I also discovered another bug while playing with the ReportAddRecordEx sample. I'm doing a new discussion thread for this one. |
||
Win 7 x64 VS 2008 CJ 15.13 |
||
apautrot
Groupie Joined: 16 April 2009 Location: France Status: Offline Points: 18 |
Post Options
Thanks(0)
|
|
Ok I have a new clue for you, it also bugs with my function ExpandRows when using BeginUpdate/EndUpdate before and after the call.
|
||
Win 7 x64 VS 2008 CJ 15.13 |
||
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
|
I know that 13.0 did not fix this problem - only 13.1 - this is why I asked forum to test static app based on new code
|
||
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 |