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 recommended installation approach, the code for running the project, and links to additional resources.

As of version 17.0.0, Angular makes standalone component enabled by default. If you use NgModules, refer to these articles:

The standalone components in Angular streamline development by removing the need for NgModules, reducing complexity, and enhancing component reuse and modularity. This approach simplifies dependency management, making applications more maintainable and scalable.

ninja-iconThe Installation 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.Start Free Trial

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

Change Theme
Theme
Loading ...

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

The following command demonstrates an efficient, automated method for adding packages using the Angular CLI through the ng-add command. This approach saves time and effort by executing a series of commands in a single step, which otherwise need to be run individually. Refer to the Manual Setup for more details.

To add the Kendo UI for Angular PivotGrid package:

  1. Run the following command:

    sh
    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.
    • Add all required peer dependencies to the package.json file.
    • Register the Kendo UI Default theme in the angular.json file.
    • Trigger npm install to install the theme and all peer packages that are added.
  2. Import the KENDO_PIVOTGRID utility array in your standalone component to enable the entire feature set of the PivotGrid:

    The utility array is available starting from v16.6.0. If you use an older version of the package, please follow the approach from the Using Kendo Angular Components with NgModules article.

    ts
    import { Component } from '@angular/core';
    import { KENDO_PIVOTGRID } from '@progress/kendo-angular-pivotgrid';
    
    @Component({
        standalone: true,
        selector: 'my-app',
        imports: [KENDO_PIVOTGRID]
    })

Using the Component

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

    html
    <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:

    ts
    [
        {
            "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:

    ts
    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

    ts
    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

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

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

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

    sh
    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

Learning Resources