Hi Travis,
Please find our response as below:
|
S.No. |
Query |
Description |
|
1. |
Is it possible to change the header text of the Grand Totals rows/columns to something like "Total"? |
Yes. You can customize the grand total string header values by replacing the custom values into the ‘FormattedText’ property of PivotCellInfo.
Please refer the below code snippet:
|
#Form1.cs
public Form1()
{
InitializeComponent();
this.InitializePivotGrid();
//Customize the row grand total string value.
for (int row = this.pivotGridControl1.PivotEngine.RowCount - 1; row >= 0; row--)
{
PivotCellInfo cellInfo = this.pivotGridControl1.PivotEngine[row, 0];
if (cellInfo != null && cellInfo.FormattedText != null && cellInfo.CellType == (PivotCellType.RowHeaderCell | PivotCellType.GrandTotalCell))
{
cellInfo.FormattedText = "Total";
break;
}
}
//Customize column grand total string value.
for (int column = this.pivotGridControl1.PivotEngine.ColumnCount - 1; column >= 0; column--)
{
PivotCellInfo cellInfo = this.pivotGridControl1.PivotEngine[0, column];
if (cellInfo != null && cellInfo.FormattedText != null && cellInfo.CellType == (PivotCellType.ColumnHeaderCell | PivotCellType.GrandTotalCell))
{
cellInfo.FormattedText = "Total";
break;
}
}
} |
|
|
2. |
Also, is there a way to ignore the Grand totals rows / columns when selecting a range? I have it set up to where a pre-determined range is selected as it loops through a filter list. A problem I have run into is even when the totals rows /cols are hidden they are still actually present and they are selected when a filter item does not include all of the original columns or rows. |
Yes. You can enable/disable the grand total rows and columns by using the ‘ShowGrandTotals’ property of PivotEngine. If you want to ignore the grand totals rows/columns while selecting the ranges, you can skip your operation by checking the condition if the cell type is grand total cell.
Please refer the below code snippet:
|
#Form1.cs
public Form1()
{
InitializeComponent();
this.InitializePivotGrid();
//To hide the grand totals.
this.pivotGridControl1.PivotEngine.ShowGrandTotals = false;
this.pivotGridControl1.TableControl.Model.SelectionChanged += Model_SelectionChanged;
}
private void Model_SelectionChanged(object sender, GridSelectionChangedEventArgs e)
{
bool allowSelection = e.Range.ToString().Contains(":");
if (allowSelection)
{
for (int row = e.Range.Top; row <= e.Range.Bottom; row++)
{
for (int column = e.Range.Left; column <= e.Range.Right; column++)
{
PivotCellInfo cellInfo = this.pivotGridControl1.PivotEngine[row - 1, column - 1];
if (cellInfo != null && cellInfo.FormattedText != null && cellInfo.CellType.ToString().Contains("GrandTotal"))
{
//to restrict the cell selection for grand total rows/columns.
this.pivotGridControl1.TableModel.Selections.Clear();
}
}
}
}
}
|
|
Please find our working sample from the following location:
If the above solution does not meet your actual requirement, could you please share the detailed description about your requirement, it would be helpful to provide the solution at the earliest.
Regards,
Thirupathi B.