Hello there
I'm trying to expand all Rows programmatically which _usually_ works with the following code:
var filterViewModels = PivotGrid.DataSource.Rows.Where(fvm => fvm is IFilterViewModel).ToList();
for (int i = 0; i < filterViewModels.Count; i++) { var filterViewModel = filterViewModels[i] as IFilterViewModel; if (i == filterViewModels.Count - 1) { ((DataSourceBase)PivotGrid.DataSource).ExpandToLevelAsync(filterViewModel, filterViewModel.Hierarchy.Levels.Count - 1).ContinueWith( (t) => PivotGrid.DataSource.RefreshGrid(), TaskContinuationOptions.ExecuteSynchronously); } else { ((DataSourceBase)PivotGrid.DataSource).ExpandToLevelAsync(filterViewModel, filterViewModel.Hierarchy.Levels.Count - 1); } }
##################
I used the word usually because in certain environments my application hangs on "PivotGrid.DataSource.RefreshGrid()" (hangs means doesn't respond to anything while having 0% CPU usage)
This occurs on 2 PCs with the same configuration:
HP Compaq Elite 8300 SFF
Intel Core i5-3570Win 7 32 bit
This Error occurs only when i try to expand all rows programmatically (using the "+"-indicators of the UI works as expected),
expanding single Nodes by Code (eg. when restoring a previous saved state of the grid) works flawlessly.
Does anyone have an Idea how to fix/avoid this? I really need this functionality...
BR
Hello,
How many hierarchies you operate with when this happen? Could you try to refresh grid once you have all nodes expanded. I mean if you collect the task objects which ExpandToLevelAsync return and then refresh the grid:
Task.Factory.ContinueWhenAll(tasks.ToArray(), t => PivotGrid.DataSource.RefreshGrid(), TaskContinuationOptions.ExecuteSynchronously);
Regards,Plamen.
Hello Plamen,
I'm operating with one Hierarchy with 4 Levels beneath, i attached 2 screenshots to illustrate what i'm doing.
The Code you provided me with didn't change that behaviour - As soon as RefreshGrid is called the Application stops.
BR,
Daniel
####
There are indeed differences in .net versions:
The PC that's having problems is running .net 4.0.30319 whilst my pc (and AFAIC all other machines i tested with) is running 4.5.50709.
Is it acceptable for you and what would be impact of updating to .NET4.5?
Thanks,Plamen
Hi Plamen,
unfortunately it's a customer's environment so i have no impact on which version of .NET is installed.
I have logged this behavior with our developers in our tracking system, with an issue ID of 144614. The next step will be for a developer to review my investigation and confirm my findings or to offer a fix, or other resolution. I will leave this case open and update you with this information after the review. You can also continue to send updates to this case at any time. I have also created a support ticket on your behalf with number CAS-117816-B7R7P1 in order to link the development issue to it so that you are automatically updated when a Service Release containing your fix is available for download.
You can view the status of all development issues connected to this case from the "Development Issues" tab, when viewing this case on the "My Support Requests" page of our website.
Best regards,Plamen
I'm facing exactly the same issue. This seems to be bug which came with Version 13.1 because with the XamPivotGrid in Version 12.2 same function works fine.
To investigate the problem I polled the IsBusy-Flag and can see that this flag is always set to true and runs in an infinit loop.
Can you commit that there is a bug in your control and can you tell me when it is fixed or do have a workaround?
Task expandTask = ( (DataSourceBase)pivotGrid.DataSource ).ExpandToLevelAsync(filterViewModel,filterViewModel.Hierarchy.Levels.Count -1);
expandTask.Wait();
pivotGrid.DataSource.RefreshGrid();
while (pivotGrid.DataSource.IsBusy)
{
Thread.Sleep(100);
}
Hello mwicke,
I have been looking into this for you and created a test sample to your specification (Pivot_tasks.zip) running under version 13.1. When I run it and press the expand button first the top XamPivotGrid’s Columns expand and then the bottom XamPivotGrid’s Columns expand too. I have attached the sample for your reference please let me know, if you can reproduce the behavior you described using it, or please modify it so it does.
Looking forward to hearing from you.
No answer?
I tried your suggestion but this also doesn't work. The problem is that RefreshGrid is called but freezes the application before ResultChanged event is fired.
I figured out how to reproduce the behavior. If you call my ExpandAll function with two pivot grids one after another the expanding works:
MyXamPivotGrid1.ExpandAll();
MyXamPivotGrid2.ExpandAll();
But if I'm using the callback as shown below it leads to the described freezing error:
MyXamPivotGrid1.ExpandAllHeaders(
() => MyXamPivotGrid2.ExpandAllHeaders());
But my Problem is that I have to use the callbacks to know when the expansion is finished and then start an excel export of the grids.
It would be nice if you could try to reproduce this with an own sample (Two filled pivot grids expanding with my function in callback).
As mentioned all worked before I upgraded to the new NetAdvantage Version 13.1. so could it be that your development team maybe changed something in the RefreshGrid method?
Regards
When you have to expand multiple hierarchies my suggestion is to collect all your task objects in a list and call RefreshGrid() once all tasks are completed:
Task.Factory.ContinueWhenAll(tasks.ToArray(),
t => dataSource.RefreshGrid(), TaskContinuationOptions.ExecuteSynchronously);
Hello Petar,
sorry for my misleading sample. This was just to demonstrate that even if you wait for the task (what makes this asynchron task kind of synchron) the RefreshGrid() is causing the program to freeze.
I've now tried your suggestions but they also have the same effect. Here is my original code, an extension method for the XamPivotGrid which I'm calling in my ViewModel classes not in code behind of the view:
public static void ExpandAllHeaders(this XamPivotGrid pivotGrid, Action callback = null)
var filterViewModels = pivotGrid.DataSource.Rows.Concat(pivotGrid.DataSource.Columns).Where(fvm => fvm is IFilterViewModel).ToList();
for (int i = 0; i < filterViewModels.Count; i++)
var filterViewModel = filterViewModels[i] as IFilterViewModel;
if (filterViewModel == null)
return;
if (i == filterViewModels.Count - 1)
EventHandler<ResultChangedEventArgs> handler = null;
handler = (sender, e) =>
pivotGrid.DataSource.ResultChanged -= handler;
if (callback != null)
callback();
};
pivotGrid.DataSource.ResultChanged += handler;
( (DataSourceBase)pivotGrid.DataSource ).ExpandToLevelAsync(filterViewModel, filterViewModel.Hierarchy.Levels.Count - 1)
.ContinueWith(t => { pivotGrid.DataSource.RefreshGrid(); }, System.Threading.Tasks.TaskContinuationOptions.ExecuteSynchronously);
else
( (
DataSourceBase)pivotGrid.DataSource ).ExpandToLevelAsync(filterViewModel, filterViewModel.Hierarchy.Levels.Count - 1);