Getting Started with the Kendo UI for Angular PivotGrid

This guide provides the information you need to start using the Kendo UI for Angular PivotGrid—it includes instructions about the available installation approaches, the required dependencies, the code for running the project, and links to additional resources.

The PivotGrid Package is part of Kendo UI for Angular, a professional grade UI library with 110+ components for building modern and feature-rich applications. To try it out sign up for a free 30-day trial.

After the completion of this guide, you will be able to achieve an end result as demonstrated in the following example.

Example
View Source
Change Theme:

Setting Up Your Angular Project

Before you start with the installation of any Kendo UI for Angular control, ensure that you have a running Angular project. The prerequisites to accomplish the installation of the components are always the same regardless of the Kendo UI for Angular package you want to use, and are fully described in the section on setting up your Angular project.

Installing the Component

You can choose to use either of the following two approaches for installing the Kendo UI for Angular package and the styles you want to apply:

Quick Setup with Angular CLI

The quick setup presents an automatic approach for adding packages with Angular CLI through the ng-add command. It is suitable for saving time and efforts as ng-add executes in a single step a set of otherwise individually needed commands.

To add the Kendo UI for Angular PivotGrid package, run the following command:

ng add @progress/kendo-angular-pivotgrid

As a result, the ng-add command will perform the following actions:

  • Add the @progress/kendo-angular-pivotgrid package as a dependency to the package.json file.
  • Import the PivotGridModule in the current application's main module (only if the application uses NgModules).

    If your application uses standalone components, you must import the PivotGridModule manually.

  • Register the Kendo UI Default theme in the angular.json file.
  • Add all required peer dependencies to the package.json file.
  • Trigger npm install to install the theme and all peer packages that are added.

Manual Setup

The manual setup provides greater visibility and better control over the files and references installed in your Angular application. You can install the required peer dependencies and a Kendo UI theme by running separate commands for each step and import the desired component modules in your NgModule.

  1. Install the PivotGrid package together with its dependencies by running the following command:

    npm install --save @progress/kendo-angular-pivotgrid @progress/kendo-data-query @progress/kendo-angular-l10n @progress/kendo-angular-intl @progress/kendo-angular-common @progress/kendo-licensing @progress/kendo-angular-icons
  2. To add the PivotGrid component, import the PivotGridModule either in your NgModule or standalone components.

    • Using Modules

      import { NgModule } from "@angular/core";
      import { BrowserModule } from "@angular/platform-browser";
      import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
      import { PivotGridModule } from "@progress/kendo-angular-pivotgrid";
      import { AppComponent } from "./app.component";
      
      @NgModule({
      imports: [
          BrowserModule,
          BrowserAnimationsModule,
          PivotGridModule,
      ],
      declarations: [AppComponent],
      bootstrap: [AppComponent],
      })
      
      export class AppModule {}
    • Using Standalone Components

      import { Component } from '@angular/core';
      import { PivotGridModule } from "@progress/kendo-angular-pivotgrid";
      
      @Component({
          standalone: true,
          selector: 'my-app',
          imports: [PivotGridModule],
          template: `
              <kendo-pivotgrid></<kendo-pivotgrid>
          `
      })
  3. The next step is to style the component by installing one of the available Kendo UI themes—Kendo UI Default, Kendo UI Material, or Kendo UI Bootstrap.

    3.1 To start using a theme, install its package through NPM.

    • Default theme

      npm install --save @progress/kendo-theme-default
    • Bootstrap theme

      npm install --save @progress/kendo-theme-bootstrap
    • Material theme

      npm install --save @progress/kendo-theme-material

    3.2 After the theme package is installed, reference it in your project. You can include kendo-themes in your project in one of the following ways:

Using the Component

  1. After successfully installing the PivotGrid package and importing its module, add the following code in the app.component.html file:

    <kendo-pivotgrid
        [kendoPivotLocalBinding]="data"
        [dimensions]="dimensions"
        [measures]="measures"
        [rowAxes]="defaultRowAxes"
        [columnAxes]="defaultColumnAxes"
        [measureAxes]="defaultMeasureAxes"
    >
    </kendo-pivotgrid>
  2. Bind the kendoPivotLocalBinding directive to an array of data items representing the PivotGrid data items by adding the following code in the app.component.ts file:

    [
        {
            "Product": "Chai",
            "Category": "Beverages",
            "Price": 18,
            "Region": "North America",
            "Country": "United States"
        },
        {
            "Product": "Chang",
            "Category": "Beverages",
            "Price": 19,
            "Region": "Europe",
            "Country": "Italy"
        },
        ...
    ]
  3. Bind the dimensions input to an array of task dependencies by adding the following code in the app.component.ts file:

    public dimensions: { [key: string]: Dimension } = {
        Category: {
          caption: "Categories",
          displayValue: (item) => item.Category,
          sortValue: (displayValue: string) => displayValue
        },
        Product: {
          caption: "Products",
          displayValue: (item) => item.Product,
          sortValue: (displayValue: string) => displayValue
        },
        Region: {
          caption: "Regions",
          displayValue: (item) => item.Region,
          sortValue: (displayValue: string) => displayValue
        },
        Country: {
          caption: "Countries",
          displayValue: (item) => item.Country,
          sortValue: (displayValue: string) => displayValue
        }
    };
  4. Bind the measures

    public measures: Measure[] = [
        { name: "Total", value: (item) => item.Price, aggregate: sumAggregate },
        { name: "Max", value: (item) => item.Price, aggregate: maxAggregate },
        { name: "Min", value: (item) => item.Price, aggregate: minAggregate },
        { name: "Average", value: (item) => item.Price, aggregate: averageAggregate }
    ];
  5. Bind the rowAxes

    public rowAxes: PivotGridAxis[] = [
        { name: ["Region"], expand: true },
        { name: ["Country"] }
    ];
  6. Bind the columnAxes

    public columnAxes: PivotGridAxis[] = [
        { name: ["Category"], expand: true },
        { name: ["Product"] }
    ];
  7. Bind the measureAxes

    public measureAxes: PivotGridAxis[] = [{ name: ["Total"] }];
  8. Build and serve the application by running the following command in the root folder.

    ng serve
  9. Point your browser to http://localhost:4200 to see the Kendo UI for Angular PivotGrid component on the page.

Activating Your License Key

As of December 2020, using any of the UI components from the Kendo UI for Angular library requires either a commercial license key or an active trial license key. If your application does not contain a Kendo UI license file, activate your license key.

Next Steps

Dependencies

The following table lists the specific functionalities that are provided by each of the PivotGrid dependencies as per package:

Package NameDescription
@angular/commonProvides the commonly-needed services, pipes, and directives provided by the Angular team. For more information, refer to the official Angular documentation.
@angular/coreContains critical runtime parts of the Angular framework that are needed by every application. For more information, refer to the official Angular documentation.
@angular/formsProvides support for both template-driven and reactive forms. For more information, refer to the official Angular documentation.
@angular/animationsContains the library of Angular animations. For more information, refer to the official Angular documentation.
@angular/platform-browserContains all DOM- and browser-related utilities for executing Angular applications on different browsers. For more information, refer to the official Angular documentation.
@progress/kendo-angular-commonContains common utilities that are needed by every Kendo UI for Angular component.
@progress/kendo-angular-l10nProvides the globalization features of Kendo UI for Angular.
@progress/kendo-angular-iconsProvides the Kendo UI for Angular Icons.
@progress/kendo-angular-intlProvides the Kendo UI for Angular services and pipes for the parsing and formatting of dates and numbers.
@progress/kendo-data-queryContains the Kendo UI Data Query utilities for applying sorting, filtering, grouping, and aggregate data operations.
@progress/kendo-licensingContains the kendo-ui-license CLI Tool for license management and the validatePackage function and type definitions that are used by licensed packages.
rxjsProvides the RxJS library for reactive programming which uses Observables for an easier composition of asynchronous or callback-based code.

Learning Resources