We use xampivotgrid in our solution and we would like to show the sums at the top instead of bottom - We already tried a solution that works for the total over all (just inserting the row with the header "All" to row[0]), but fails for the subtotals.
The Code for moving the total sum to top looks like follows:
PivotDataRow sumrow = pivotGrid.GridLayout.Rows.First(s => s.HeaderText == "All" || (s.HeaderText.StartsWith("All/") && s.HeaderText.EndsWith("/All"))); pivotGrid.GridLayout.Rows.Insert(0, sumrow);
The Code for moving subtotals to the top looks at follows:
foreach (PivotDataRow innersum in pivotGrid.GridLayout.Rows.Where(r => r.HeaderText.EndsWith("All") && !r.HeaderText.StartsWith("All")).ToList()) { string header = innersum.HeaderText.Substring(0, innersum.HeaderText.Length - 4); int newindex = pivotGrid.GridLayout.Rows.IndexOf(pivotGrid.GridLayout.Rows.First(r => r.HeaderText.StartsWith(header))); pivotGrid.GridLayout.Rows.Insert(newindex, innersum); }
We also tried not moving the rows immediately but storing them in a dictionary (along with the new index) and performing the movings after all rows to move have been determined - But we either get an exception or an empty grid.
Is there any built-In function for this or do you have any advice how this could be done?
BR
Hello,
There are two XamPivotGrid properties which will allow you to control the position of the total: ParentInFrontForColumns and ParentInFrontForRows.
Best regards.Plamen.
Works - Thank you!