Percentage Types
- 4 minutes to read
Percentage summary display types are designed to show cell values as a percentage of the Total and Grand Total values in data cells. To employ these types, use PercentOfTotalBinding in Optimized mode.
Note
In percentage summary display types, values are automatically formatted as percentages. To specify custom formatting settings, use the data field’s PivotGridFieldBase.CellFormat property.
The following percentage types are available:
Percent of Column Total
The percentage of the Column Total value is displayed in a cell.
Example
void SetSelectedSummaryDisplayType() {
if(SummaryDisplayTypeDataField == null)
return;
DataSourceColumnBinding sourceBinding = new DataSourceColumnBinding(SourceDataFieldName);
switch(ddlSummaryDisplayType.SelectedItem.Text) {
// ...
case "PercentOfColumn":
SummaryDisplayTypeDataField.DataBinding = new PercentOfTotalBinding(
sourceBinding,
CalculationPartitioningCriteria.ColumnValueAndRowParentValue);
SummaryDisplayTypeDataField.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
SummaryDisplayTypeDataField.CellFormat.FormatString = "p2";
break;
// ...
}
SummaryDisplayTypeDataField.Caption = string.Format("{0}", ddlSummaryDisplayType.SelectedItem.Text);
}
Note
Set PivotGridFieldBase.SummaryDisplayType to PivotSummaryDisplayType.PercentOfColumn in Legacy and LegacyOptimized modes.
Percent of Column Grand Total
The percentage of the Column Grand Total value is displayed in a cell.
Example
void SetSelectedSummaryDisplayType() {
if(SummaryDisplayTypeDataField == null)
return;
DataSourceColumnBinding sourceBinding = new DataSourceColumnBinding(SourceDataFieldName);
switch(ddlSummaryDisplayType.SelectedItem.Text) {
// ...
case "PercentOfColumnGrandTotal":
SummaryDisplayTypeDataField.DataBinding = new PercentOfTotalBinding(
sourceBinding,
CalculationPartitioningCriteria.ColumnValue);
SummaryDisplayTypeDataField.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
SummaryDisplayTypeDataField.CellFormat.FormatString = "p2";
break;
// ...
}
SummaryDisplayTypeDataField.Caption = string.Format("{0}", ddlSummaryDisplayType.SelectedItem.Text);
}
Note
Set PivotGridFieldBase.SummaryDisplayType to PivotSummaryDisplayType.PercentOfColumnGrandTotal in Legacy and LegacyOptimized modes.
Percent of Row Total
The percentage of the Row Total value is displayed in the cell.
Example
void SetSelectedSummaryDisplayType() {
if(SummaryDisplayTypeDataField == null)
return;
DataSourceColumnBinding sourceBinding = new DataSourceColumnBinding(SourceDataFieldName);
switch(ddlSummaryDisplayType.SelectedItem.Text) {
// ...
case "PercentOfRow":
SummaryDisplayTypeDataField.DataBinding = new PercentOfTotalBinding(
sourceBinding,
CalculationPartitioningCriteria.RowValueAndColumnParentValue);
SummaryDisplayTypeDataField.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
SummaryDisplayTypeDataField.CellFormat.FormatString = "p2";
break;
// ...
}
SummaryDisplayTypeDataField.Caption = string.Format("{0}", ddlSummaryDisplayType.SelectedItem.Text);
}
Note
Set PivotGridFieldBase.SummaryDisplayType to PivotSummaryDisplayType.PercentOfRow in Legacy and LegacyOptimized modes.
Percent of Row Grand Total
The percentage of the Row Grand Total value is displayed in a cell.
Example
void SetSelectedSummaryDisplayType() {
if(SummaryDisplayTypeDataField == null)
return;
DataSourceColumnBinding sourceBinding = new DataSourceColumnBinding(SourceDataFieldName);
switch(ddlSummaryDisplayType.SelectedItem.Text) {
// ...
case "PercentOfRowGrandTotal":
SummaryDisplayTypeDataField.DataBinding = new PercentOfTotalBinding(
sourceBinding,
CalculationPartitioningCriteria.RowValue);
SummaryDisplayTypeDataField.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
SummaryDisplayTypeDataField.CellFormat.FormatString = "p2";
break;
// ...
}
SummaryDisplayTypeDataField.Caption = string.Format("{0}", ddlSummaryDisplayType.SelectedItem.Text);
}
Note
Set PivotGridFieldBase.SummaryDisplayType to PivotSummaryDisplayType.PercentOfRowGrandTotal in Legacy and LegacyOptimized modes.
Percent of Grand Total
The percentage of the Grand Total value is displayed in a cell.
Example
void SetSelectedSummaryDisplayType() {
if(SummaryDisplayTypeDataField == null)
return;
DataSourceColumnBinding sourceBinding = new DataSourceColumnBinding(SourceDataFieldName);
switch(ddlSummaryDisplayType.SelectedItem.Text) {
// ...
case "PercentOfGrandTotal":
SummaryDisplayTypeDataField.DataBinding = new PercentOfTotalBinding(
sourceBinding,
CalculationPartitioningCriteria.None);
SummaryDisplayTypeDataField.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
SummaryDisplayTypeDataField.CellFormat.FormatString = "p2";
break;
// ...
}
SummaryDisplayTypeDataField.Caption = string.Format("{0}", ddlSummaryDisplayType.SelectedItem.Text);
}
Note
Set PivotGridFieldBase.SummaryDisplayType to PivotSummaryDisplayType.PercentOfGrandTotal in Legacy and LegacyOptimized modes.