New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Conditional Formatting

empty
TotalPriceQuantityYearQuarter
CategoryProductName
empty
19971997 Sum of TotalPrice1997 Sum of Quantity 19981998 Sum of TotalPrice1998 Sum of QuantityTotal Sum of TotalPriceTotal Sum of Quantity
Quarter 1Quarter 2Quarter 3Quarter 4Quarter 1Quarter 2Quarter 3Quarter 4
Sum of TotalPriceSum of QuantitySum of TotalPriceSum of QuantitySum of TotalPriceSum of QuantitySum of TotalPriceSum of QuantitySum of TotalPriceSum of QuantitySum of TotalPriceSum of QuantitySum of TotalPriceSum of QuantitySum of TotalPriceSum of Quantity
empty
BeveragesChartreuse verte
Côte de Blaye
Guaraná Fantástica
Ipoh Coffee
Lakkalikööri
Laughing Lumberjack Lager
Outback Lager
Rhönbräu Klosterbier
Sasquatch Ale
Steeleye Stout
Grand Total
empty
$3,582.00199$414.0023$554.4036$378.0025$4,928.40283  $1,422.0079$2,394.00133$540.0030$4,356.00242$9,284.40525
$7,905.0030$33,780.70148  $10,276.5045$51,962.20223$6,587.5025$18,445.0070$26,350.00100$17,127.5065$68,510.00260$120,472.20483
$450.00100$157.5035$513.00118$636.30168$1,756.80421$630.00140$270.0060$657.00146$900.00200$2,457.00546$4,213.80967
$2,990.0065$4,186.0091$3,680.0084$662.4018$11,518.40258$2,760.0060$3,542.0077  $2,254.0049$8,556.00186$20,074.40444
$630.0035$1,569.6094$2,311.20132$3,196.80186$7,707.60447$2,628.00146$1,674.0093$180.0010$2,502.00139$6,984.00388$14,691.60835
$462.0033$448.0032    $910.0065$280.0020  $420.0030$896.0064$1,596.00114$2,506.00179
$1,350.0090$801.0055$2,040.00141$1,689.00127$5,880.00413$1,035.0069$1,440.0096$1,245.0083  $3,720.00248$9,600.00661
$1,650.75213$658.7585$1,475.60196$982.70136$4,767.80630$232.5030$155.0020$1,038.50134$1,681.75217$3,107.75401$7,875.551031
$140.0010$140.0010$1,148.0086$812.0065$2,240.00171$2,520.00180$490.0035$140.0010$280.0020$3,430.00245$5,670.00416
$864.0048$2,376.00151$1,015.2058$1,602.0089$5,857.20346$2,106.00117$1,062.0059$666.0037$900.0050$4,734.00263$10,591.20609
$157,389.345390$158,584.775970$132,285.605684$127,371.494934$575,631.2021978$117,300.563800$102,583.633473$91,805.602516$87,426.602970$399,116.3912759$974,747.5934737
Page size:

legend

TotalPrice column and row totals:
  • > 10,000
  • 5,000 - 10,000
  • < 5,000
Quantity column and row totals
  • > 200
  • 100 - 200
  • < 100
TotalPrice column and row grand totals:
  • > 100,000
  • < 100,000
Legend for TotalPrice column and row totals:
  • > 5,000
  • < 5,000

This demo shows how one can apply a custom style to RadPivotGrid data and aggregate cells conditionally. You can see various ways of accessing groups of cells or specific ones, including:

  • Using only the cell type
  • Using indexes (which in RadPivotGrid are multi-dimensional arrays)
  • Using the cell type and DataField of the cell

As shown in the demo, the two main events that can be used for accessing cells are:

  • CellDataBound which is fired for each cell that is bound in the control.
  • PreRender where all cells are already created and populated and you can access them using the RadPivotGrid server-side API
  • DefaultCS.aspx
  • DefaultCS.aspx.cs
  • styles.css
<%@ Page Language="C#" Inherits="Telerik.PivotGridExamplesCSharp.Appearance.ConditionalFormatting.DefaultCS"CodeFile="DefaultCS.aspx.cs"  %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
    <link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
        <telerik:RadPivotGrid RenderMode="Lightweight" ID="RadPivotGrid1" runat="server" OnNeedDataSource="RadPivotGrid1_NeedDataSource"
            OnDataBound="RadPivotGrid1_DataBound" Height="500px" OnCellDataBound="RadPivotGrid1_CellDataBound"
            AllowFiltering="false" ShowFilterHeaderZone="false" OnPreRender="RadPivotGrid1_PreRender"
            AllowSorting="true" AllowPaging="true">
            <Fields>
                <telerik:PivotGridRowField DataField="Category">
                </telerik:PivotGridRowField>
                <telerik:PivotGridRowField DataField="ProductName">
                </telerik:PivotGridRowField>
                <telerik:PivotGridColumnField DataField="Year">
                </telerik:PivotGridColumnField>
                <telerik:PivotGridColumnField DataField="Quarter" DataFormatString="Quarter {0}">
                </telerik:PivotGridColumnField>
                <telerik:PivotGridAggregateField DataField="TotalPrice" Aggregate="Sum" DataFormatString="{0:C}">
                </telerik:PivotGridAggregateField>
                <telerik:PivotGridAggregateField DataField="Quantity" Aggregate="Sum">
                </telerik:PivotGridAggregateField>
            </Fields>
            <ClientSettings>
                <Scrolling AllowVerticalScroll="true" ScrollHeight="360px"></Scrolling>
            </ClientSettings>
        </telerik:RadPivotGrid>
    </telerik:RadAjaxPanel>
    <div class="demo-container" style="background-color: white">
        <div class="legendWrapper">
            <h3>legend</h3>
            <div>
                <div class="legend">
                    <span>TotalPrice column and row totals:</span>
                    <ul>
                        <li>
                            <span class="colorBox" style="background-color: rgb(247, 148, 117)"></span>&gt; 10,000
                        </li>
                        <li>
                            <span class="colorBox" style="background-color: rgb(248, 169, 145)"></span>5,000 - 10,000
                        </li>
                        <li>
                            <span class="colorBox" style="background-color: rgb(250, 202, 186)"></span>&lt; 5,000
                        </li>
                    </ul>
                </div>
                <div class="legend">
                    <span>Quantity column and row totals</span>
                    <ul>
                        <li>
                            <span class="colorBox" style="background-color: rgb(250, 193, 118)"></span>&gt; 200
                        </li>
                        <li>
                            <span class="colorBox" style="background-color: rgb(251, 209, 153)"></span>100 - 200
                        </li>
                        <li>
                            <span class="colorBox" style="background-color: rgb(252, 224, 187)"></span>&lt; 100
                        </li>
                    </ul>
                </div>
                <div class="legend">
                    <span>TotalPrice column and row grand totals:</span>
                    <ul>
                        <li>
                            <span class="colorBox" style="background-color: rgb(110, 180, 208)"></span>&gt; 100,000
                        </li>
                        <li>
                            <span class="colorBox" style="background-color: rgb(167, 210, 227)"></span>&lt; 100,000
                        </li>
                    </ul>
                </div>
                <div class="legend">
                    <span>Legend for TotalPrice column and row totals:</span>
                    <ul>
                        <li>
                            <span class="colorBox" style="background-color: rgb(130, 199, 241)"></span>&gt; 5,000
                        </li>
                        <li>
                            <span class="colorBox" style="background-color: rgb(172, 218, 246)"></span>&lt; 5,000
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance