Skip to main content

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.

SummmaryDisplayMode_PercentOfColumn

Example

View Example: Pivot Grid for Web Forms - How to Change the Summary Display Mode

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);
}

Percent of Column Grand Total

The percentage of the Column Grand Total value is displayed in a cell.

SummaryDisplayType_PercentOfColumnGrandTotal

Example

View Example: Pivot Grid for Web Forms - How to Change the Summary Display Mode

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);
}

Percent of Row Total

The percentage of the Row Total value is displayed in the cell.

SummmaryDisplayMode_PercentOfRow

Example

View Example: Pivot Grid for Web Forms - How to Change the Summary Display Mode

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.

SummaryDisplayType_PercentOfRowGrandTotal

Example

View Example: Pivot Grid for Web Forms - How to Change the Summary Display Mode

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);
}

Percent of Grand Total

The percentage of the Grand Total value is displayed in a cell.

SummaryDisplayType_PercentOfGrandTotal

Example

View Example: Pivot Grid for Web Forms - How to Change the Summary Display Mode

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);
}
See Also