Hi,
I modified the pivotGrid DataSource and did a RefreshGrid.
After refresh I can't scroll through all my items in the grid. The scrollbar changed and lets me scroll through only some of the items.
Looks like a bug.
Could you please suggest a work around.
Hello Sangeetha,
I am just checking have you been able to resolve your issue. If you need any further assistance on the matter, please do not hesitate to ask.
I investigated your issue and I followed the steps that you described, however I am not able to reproduce the scrolling issue. Could you please modify the attached sample so the incorrect behavior is reproducible.
Thanks in advance.
Sure Elena,
(1) Turn totals off and expand grid in PivotGrid_LayoutLoaded event as mentioned in the earlier message.
(2) Edit the PivotGrid's FlatDataSource and refresh using pivotGrid.DataSource.Refresh() as follows:
{
...
FlatDataSource fds = pivotGrid.DataSource as FlatDataSource; Type t = fds.ItemsSource.GetType(); counter = 0; IEnumerator enumerator = fds.ItemsSource.GetEnumerator(); while (enumerator.MoveNext()) { Type type = enumerator.Current.GetType(); string indexName = type.GetProperty("Index Name").GetValue(enumerator.Current, null) as string; if (indexName.Equals(selectedIndex)) { double dval = 0; try { object oval = type.GetProperty(selectedValueColumn).GetValue(enumerator.Current, null); dval = double.Parse(oval.ToString()); } catch (Exception ex) { } type.GetProperty(selectedValueColumn).SetValue(enumerator.Current, dval + shift + (step * counter++), null); } } pivotGrid.DataSource.RefreshGrid();
}
I resolved the problems as follows:
===========================
(1) Toggle Totals visibility via a MenuItem
(2) Expand hierarchy as follows:
private void OnPivotGrid_ResultChanged(object sender, AsyncCompletedEventArgs e) { var dataSource = pivotGrid.DataSource; if (dataSource != null) { IResult result = dataSource.Result; if (result != null) { if (!_axisExpansionChangedManually) { IResultAxis axis = dataSource.Result.RowAxis; if (axis != null) { // expand the first row hierarchy, if it exists IMember firstRowMember = axis.Tuples.First().Members.First(); if (firstRowMember.Members.Count != 0) dataSource.SwitchAxisMember(firstRowMember); } } _axisExpansionChangedManually = false; } } //pivotGrid.DataSource.ResultChanged -= xamPivotGrid_ResultChanged; }
Hope that helps.
Thanks
Sangeetha
I was reviewing your issue and I am not able to reproduce it. Could you please provide me with a small sample where the mentioned behavior is reproducible.
Hi Plamen,
Here is something else I noticed:
When I comment out tree expansion code and hiding totals code in LayoutLoaded event, then the scrolling seems fine. Although I can't seem to expand the Date Hierarchy Row.
Is there a better event to expand tree and hide totals?
private void PivotGrid_LayoutLoaded(object sender, EventArgs e) { // Turn off col totals foreach (PivotDataColumn col in pivotGrid.DataColumns) { if (col.IsTotal) col.IsVisible = false; } // Turn off row totals foreach (PivotDataRow row in pivotGrid.DataRows) { if (row.IsTotal) row.IsVisible = false; } // Expand Column Hierarchy foreach (PivotHeaderCell cell in pivotGrid.GridLayout.ColumnHeaderCells) { if (cell.IsToggleVisible && cell.IsExpanded == false) { cell.IsExpanded = true; return; } } // Expand Row Hierarchy foreach (PivotHeaderCell cell in pivotGrid.GridLayout.RowHeaderCells) { if (cell.IsToggleVisible && cell.IsExpanded == false) { cell.IsExpanded = true; return; } } }