Back to Devexpress

PivotFieldValueStyle.TopAlignedRowValues Property

aspnet-devexpress-dot-web-dot-aspxpivotgrid-dot-pivotfieldvaluestyle.md

latest7.1 KB
Original Source

PivotFieldValueStyle.TopAlignedRowValues Property

Gets or sets whether row values are top-aligned.

Namespace : DevExpress.Web.ASPxPivotGrid

Assembly : DevExpress.Web.ASPxPivotGrid.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
[DefaultValue(false)]
public bool TopAlignedRowValues { get; set; }
vb
<DefaultValue(False)>
Public Property TopAlignedRowValues As Boolean

Property Value

TypeDefaultDescription
Booleanfalse

true if row values are top-aligned; otherwise, false.

|

Remarks

TopAlignedRowValuesImage
true
false

Example

In this example, the ASPxPivotGrid.CustomCellStyle event is handled to specify custom style settings of individual summary cells displayed within odd rows. The PivotFieldValueStyle.TopAlignedRowValues property aligns field values to the top edge of their cells.

aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="CellAppearanceCustomization.DefaultForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table class="OptionsTable BottomMargin">
            <tr>
                <td>
                    <dx:ASPxCheckBox ID="cbApplyCustomCellAppearance" runat="server" AutoPostBack="True" Text="Apply Custom Cell Appearance" />
                </td>
                <td>
                    <dx:ASPxCheckBox ID="cbTopAlignRowFieldValues" runat="server" AutoPostBack="True" Text="Top Align Row Field Values"
                        OnCheckedChanged="cbTopAlignRowFieldValues_CheckedChanged" />
                </td>
            </tr>
        </table>
        <dx:ASPxPivotGrid ID="pivotGrid" runat="server" CssClass="dxpgControl" ClientInstanceName="pivotGrid"
            DataSourceID="CustomerReportDataSource" OnCustomCellStyle="ASPxPivotGrid1_CustomCellStyle"
            Width="100%" Height="116px">
            <Fields>
                <dx:PivotGridField Area="RowArea" AreaIndex="0" Caption="Customer" FieldName="CompanyName"
                    ID="fieldCompanyName" UnboundFieldName="" />
                <dx:PivotGridField Area="ColumnArea" AreaIndex="0" Caption="Year" FieldName="OrderDate"
                    ID="fieldOrderDate" GroupInterval="DateYear" UnboundFieldName="UnboundColumn1" />
                <dx:PivotGridField Area="DataArea" AreaIndex="0" Caption="Product Amount" FieldName="ProductAmount"
                    ID="fieldProductAmount" UnboundFieldName="" />
                <dx:PivotGridField Area="RowArea" AreaIndex="1" Caption="Products" FieldName="ProductName"
                    ID="fieldProductName" UnboundFieldName="" />
            </Fields>
            <OptionsView HorizontalScrollBarMode="Auto" />
            <OptionsLoadingPanel Text="Loading&amp;hellip;" />
            <OptionsData DataProcessingEngine="LegacyOptimized" />
            <OptionsFilter NativeCheckBoxes="False" />
        </dx:ASPxPivotGrid>
        <asp:AccessDataSource ID="CustomerReportDataSource" runat="server" DataFile="~/App_Data/nwind.mdb"
            SelectCommand="SELECT * FROM [CustomerReports]"></asp:AccessDataSource>
    </div>
    </form>
</body>
</html>
csharp
using System;
using DevExpress.XtraPivotGrid;
using System.Drawing;

namespace CellAppearanceCustomization {
    public partial class DefaultForm : System.Web.UI.Page {
        protected void Page_Load(object sender, EventArgs e) {

        }
        protected void ASPxPivotGrid1_CustomCellStyle(object sender, DevExpress.Web.ASPxPivotGrid.PivotCustomCellStyleEventArgs e) {
            if(!cbApplyCustomCellAppearance.Checked) return;
            if(e.RowIndex % 2 == 0) return;
            if(e.ColumnValueType == PivotGridValueType.Value && e.RowValueType == PivotGridValueType.Value)
                e.CellStyle.BackColor = Color.FromArgb(240, 240, 240);
            if(e.ColumnValueType == PivotGridValueType.Total || e.RowValueType == PivotGridValueType.Total)
                e.CellStyle.BackColor = Color.FromArgb(213, 227, 230);
            if(e.ColumnValueType == PivotGridValueType.GrandTotal || e.RowValueType == PivotGridValueType.GrandTotal)
                e.CellStyle.BackColor = Color.FromArgb(187, 211, 215);
        }
        protected void cbTopAlignRowFieldValues_CheckedChanged(object sender, EventArgs e) {
            pivotGrid.Styles.FieldValueStyle.TopAlignedRowValues = cbTopAlignRowFieldValues.Checked;
        }
    }
}
vb
Imports System
Imports DevExpress.XtraPivotGrid
Imports System.Drawing

Namespace CellAppearanceCustomization
    Partial Public Class DefaultForm
        Inherits System.Web.UI.Page

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

        End Sub
        Protected Sub ASPxPivotGrid1_CustomCellStyle(ByVal sender As Object, ByVal e As DevExpress.Web.ASPxPivotGrid.PivotCustomCellStyleEventArgs)
            If Not cbApplyCustomCellAppearance.Checked Then
                Return
            End If
            If e.RowIndex Mod 2 = 0 Then
                Return
            End If
            If e.ColumnValueType = PivotGridValueType.Value AndAlso e.RowValueType = PivotGridValueType.Value Then
                e.CellStyle.BackColor = Color.FromArgb(240, 240, 240)
            End If
            If e.ColumnValueType = PivotGridValueType.Total OrElse e.RowValueType = PivotGridValueType.Total Then
                e.CellStyle.BackColor = Color.FromArgb(213, 227, 230)
            End If
            If e.ColumnValueType = PivotGridValueType.GrandTotal OrElse e.RowValueType = PivotGridValueType.GrandTotal Then
                e.CellStyle.BackColor = Color.FromArgb(187, 211, 215)
            End If
        End Sub
        Protected Sub cbTopAlignRowFieldValues_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
            pivotGrid.Styles.FieldValueStyle.TopAlignedRowValues = cbTopAlignRowFieldValues.Checked
        End Sub
    End Class
End Namespace

See Also

PivotFieldValueStyle Class

PivotFieldValueStyle Members

DevExpress.Web.ASPxPivotGrid Namespace