Hi,
Is it possible to have show/hide the totals dynamically? Our users would like to do so by clicking a button.
We've been checking these posts:
http://es.infragistics.com/community/forums/t/84334.aspx
http://es.infragistics.com/community/forums/t/56405.aspx
It doesn't work very well. When we need to refresh the grid because the underlying data has changed and call PivotGrid.DataSource.RefreshGrid() the hidden rows come back.
We've tried to do the hiding/showing logic in the PivotGrid.LayoutUpdated event handler but we've noticed something else:
When the totals are hidden and we collapse any level, the level actually disappears until the we call again PivotGrid.DataSource.RefreshGrid(). This only happens when hiding the rows by setting IsVisible to false. If instead we do Height=0 this behaviour doesn't occur.
Is there a better way to handle this? Is it possible to avoid keeping hiding the rows in the LayoutUpdated event handler?
Thanks.
Is anyone looking at this?
Hi Ribao80,
For dynamically hiding and showing totals I don't think there is a better way of doing this other than setting IsVisible to false as shown in those other threads. The issue with your scenario is that since the totals have been hidden, when you collapse the level the visibility isn't being restored. The expansion of the hierarchy when the column/row is collapsed is the same column/row that handles the Totals. So if that column or row is collapsed, when you re-collapse the hierarchy the column or row is no longer visible.
A way you can resolve this is to handle the AxisExpansionChanged event and restore the totals row/column visibility. This event will provide you with a HeaderCell and this object has properties that can allow you to determine if this cell is for the totals or not and then you can reset the visibility. Something like this perhaps:
private void PivotGrid_AxisExpansionChanged(object sender, PivotAxisExpansionChangedEventArgs e){ if (e.HeaderCell.Member.IsTotal) { foreach (PivotDataRow c in pivotGrid.DataRows) { if (c.Tuple.Members.Contains(e.HeaderCell.Member) && !c.IsVisible) { c.IsVisible = true; } } }}