PivotGrid - Filtering

SafetyLevel
QuantityClass
ColorLine
M-ClassL-ClassH-ClassB-ClassGrand Total
BlackA-Line
M-Line
R-Line
T-Line
Black Total
BrownA-Line
M-Line
R-Line
T-Line
Brown Total
Grand Total
92160162617013849
81713751121 3313
821821878 2520
   697697
255927972625239810379
     
352356350 1058
344346583 1273
   497497
6967029334972828
4028370740151124322993
123
Page size:
Isolate this demo as a stand-alone application
  • About this demo
  • C#
  • VB

Filtering in RadPivotGrid is switched on/off by the AllowFiltering property. When turned on it will make RadPivotGrid display a tiny filter image beside each field’s name. This is the fields filter button which opens up the filter window. The latter allows the user to exclude data items based on unique key values or apply a wide range of filter operators that fall within two categories: Label and Value filters.

1. Label filters Label filters control which groups for a given field will remain in the pivot data view after grouping has been performed. If, in the current example, you need only the groups for the White color, you should apply an Equals label filter on the Color field.

2. Value filters Value filters, for their part, allow filtering operations to be performed on the aggregate results. If, again illustrating with the current example, you need only the data where the total Sum of Quantity for each Class does not exceed 5000 you should apply a value filter on the Class field with a LessThanOrEqual filter operator and the corresponding filter value.

3. Report filtersReport filters are applied on fields that do not participate in the grouping of the data but are still present in the underlying data source. Report filters allow the exclusion of selected field items from the data prior to its grouping. In order for a pivot grid field to become eligible for report filtering it should be added to RadPivotGrid’s fields collection as a PivotGridReportField. That will effectively make it part of the grid’s filter zone and make report filtering applicable to it. If, for example, you need to perform the grouping only on items which SafetyLevel is either 1000 or 800, you should apply the corresponding report filter to the SafetyLevel field in the filter zone of the grid.

  • DefaultCS.aspx
  • DefaultCS.aspx.cs
    • DefaultCS.aspx.cs
    • PivotGridDataSourceHelper.cs
<%@ Page Language="c#" AutoEventWireup="false" CodeFile="DefaultCS.aspx.cs" Inherits="Telerik.PivotGrid.Examples.Filtering.DefaultCS" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
</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="ajaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
            <telerik:RadPivotGrid RenderMode="Lightweight" AllowFiltering="true" Width="100%"
                AllowSorting="true" ID="RadPivotGrid1" AllowPaging="true" PageSize="10" runat="server">
                <DataCellStyle Width="100px" />
                <RowHeaderCellStyle Width="20%" />
                <ClientSettings Scrolling-AllowVerticalScroll="true">
                </ClientSettings>
                <Fields>
                    <telerik:PivotGridReportFilterField DataField="SafetyLevel" UniqueName="SafetyLevel">
                    </telerik:PivotGridReportFilterField>
                    <telerik:PivotGridRowField DataField="Color" ShowGroupsWhenNoData="true" UniqueName="Color">
                    </telerik:PivotGridRowField>
                    <telerik:PivotGridRowField DataField="Line" UniqueName="Line">
                    </telerik:PivotGridRowField>
                    <telerik:PivotGridColumnField DataField="Class" SortOrder="Descending" UniqueName="Class">
                    </telerik:PivotGridColumnField>
                    <telerik:PivotGridAggregateField DataField="Quantity">
                    </telerik:PivotGridAggregateField>
                </Fields>
            </telerik:RadPivotGrid>
        </telerik:RadAjaxPanel>
    </form>
</body>
</html>

Find Assistance

Help Us Improve

Was this example helpful?