Hi,
How can I Expand/Collapse All.
I use the following code. But it throws the exception
What am I doing wrong?
private void ExpandAll(Collection<PivotHeaderCell> pivotHeaderCells) { foreach (PivotHeaderCell cell in pivotHeaderCells) { cell.IsExpanded = true; if (cell.Children.Count > 0) CollapseAll(cell.Children); } }
Thanks
Sangeetha
Sorry, here is the right code:
private void ExpandAll(Collection<PivotHeaderCell> pivotHeaderCells) { foreach (PivotHeaderCell cell in pivotHeaderCells) { cell.IsExpanded = true; if (cell.Children.Count > 0) ExpandAll(cell.Children); } }
Hello,
I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.
If the above suggestion helped you solve your issue please verify the thread as answered so other users may take better advantage of it.
Hi Petar,
Thanks for your reply. I tried your sugestion but unfortunately could not get it to work.
I tried the approach in the link below - it doesn't always expand all hierarchies either.
http://samples.infragistics.com/sldv/RunSamples.aspx?cn=pivot-grid#/pivot-grid/expand-hierarchies
Here is my code. If you see any inconsistencies/errors please let me know.
private void ExpandAll_Click(object sender, RoutedEventArgs e)
{
BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += Worker_DoWork; worker.RunWorkerCompleted += (s, ee) => { this.pivotGrid.DataSource.DeferredLayoutUpdate = false; }; this.pivotGrid.DataSource.DeferredLayoutUpdate = true; worker.RunWorkerAsync(this.pivotGrid.DataSource);
}
ManualResetEvent manualResetEvent = new ManualResetEvent(false); void Worker_DoWork(object sender, DoWorkEventArgs e) { DataSourceBase dataSource = e.Argument as DataSourceBase; if (dataSource.Rows.Count > 0) { IFilterViewModel fvm = dataSource.Rows[0] as IFilterViewModel; if (fvm != null) { fvm.LoadFilterMembersCompleted += (sender1, e1) => { manualResetEvent.Set(); }; if (fvm != null && fvm.FilterMembers != null) { foreach (IFilterMember member in fvm.FilterMembers) { DrillIn(fvm, member); } } } } } private void DrillIn(IFilterViewModel filterViewModel, IFilterMember filterMember) { manualResetEvent = new ManualResetEvent(false); this.Dispatcher.BeginInvoke((Action)delegate() { filterMember.IsExpanded = true; }); if (filterMember.HasChildren && filterMember.FilterMembers.Count == 0) manualResetEvent.WaitOne(); foreach (IFilterMember member in filterMember.FilterMembers) { DrillIn(filterViewModel, member); } }
Hello Sangeetha,
Thank you for your post. I have been looking through it and I created a sample project for you with the functionality you want. Basically used the code from the Feature Browser and add a comment in the Click event of the Expand button where you should make some changes depending on your data. Please let me know if this helps you or you need further assistance.
Looking Forward for your reply.
Hi Stefan,
I updated my WPF to the latest Service Release 2094, and noticed that the Expand/Collapse code won't work anymore - I think Background worker has a bug in it. I just ran your sample and I see the same exception. Could you please investigate and let me know if it is a bug or some functionality changed.
I would like to know your solutiion if possible.
I got this working by using a delegate around the line I set expand/collase once I upgraded to V11.2
Thank You for your immediate reply.
Yes the solution works fine. There is one small problem though - I don't see any suitable place to turn the expand boolean off - I want to expand only when ExpandAll button is clicked, and not when just layout is updated. What would you suggest as a good place to turn this off.
Also, I would like to have a bug report created for the Background worker exception.
I tried the sample with the latest service release and everything was as you said, so I modified it by using a different logic to expand all cells, this time without BackgroundWorker, so now it works as expected.
Hope this helps.