Angular UI Components Documentation
The Angular PivotGrid displays summarized data in a multi-dimensional, cross-tabulated view. This guide adds the Angular PivotGrid (jqxPivotGrid) to an app, then shows how to set its options, handle its events and call its methods.
jqwidgets-ngjqwidgets-ng/jqxpivotgrid 
In an Angular project (to start one, see Getting started with Angular), add the package with the Angular CLI. It asks for a theme and adds the styles to angular.json:
ng add jqwidgets-ng
Components are standalone: add jqxPivotGridModule to the imports of the component that uses it.
import { Component } from '@angular/core';
import { jqxPivotGridModule } from 'jqwidgets-ng/jqxpivotgrid';
@Component({
selector: 'app-root',
imports: [jqxPivotGridModule],
templateUrl: './app.html'
})
export class App {}
The source of the live Pivot Grid Cell Values Alignment demo.
<jqxPivotGrid
[width]="getWidth()"
[height]="400"
[source]="pivotDataSource"
[treeStyleRows] = "true"
[autoResize] = "false"
[multipleSelectionEnabled] = "true"
>
</jqxPivotGrid>
import { Component } from '@angular/core';
import { jqxPivotGridComponent } from 'jqwidgets-ng/jqxpivotgrid';
import { CommonModule } from '@angular/common';
import { jqxPivotGridModule } from 'jqwidgets-ng/jqxpivotgrid';
@Component({
imports: [CommonModule, jqxPivotGridModule],
selector: 'app-root',
templateUrl: './app.html',
styleUrl: './app.css'
})
export class App {
constructor() {
this.pivotDataSource = this.createPivotDataSource();
}
pivotDataSource: null;
getWidth(): any {
if (document.body.offsetWidth < 850) {
return '90%';
}
return 850;
}
createPivotDataSource(): any {
// prepare sample data
let data = new Array();
let countries = [
'Germany',
'France',
'United States',
'Italy',
'Spain',
'Finland',
'Canada',
'Japan',
'Brazil',
'United Kingdom',
'China',
'India',
'South Korea',
'Romania',
'Greece'
];
let dataPoints = [
'2.25',
'1.5',
'3.0',
'3.3',
'4.5',
'3.6',
'3.8',
'2.5',
'5.0',
'1.75',
'3.25',
'4.0'
];
for (let i = 0; i < countries.length * 2; i++) {
let row: any = {};
let value = parseFloat(dataPoints[Math.round(Math.random() * 100) % dataPoints.length]);
row['country'] = countries[i % countries.length];
row['value'] = value;
data[i] = row;
}
// create a data source and data adapter
let source = {
localdata: data,
datatype: 'array',
datafields: [
{ name: 'country', type: 'string' },
{ name: 'value', type: 'number' }
]
};
let dataAdapter = new jqx.dataAdapter(source);
dataAdapter.dataBind();
// create a pivot data source from the dataAdapter
let pivotDataSource = new jqx.pivot(dataAdapter, {
pivotValuesOnRows: false,
rows: [{ dataField: 'country', width: 190 }],
columns: [],
values: [
{
dataField: 'value',
width: 200,
function: 'min',
text: 'cells left alignment',
formatSettings: { align: 'left', prefix: '', decimalPlaces: 2 }
},
{
dataField: 'value',
width: 200,
function: 'max',
text: 'cells center alignment',
formatSettings: { align: 'center', prefix: '', decimalPlaces: 2 }
},
{
dataField: 'value',
width: 200,
function: 'average',
text: 'cells right alignment',
formatSettings: { align: 'right', prefix: '', decimalPlaces: 2 }
}
]
});
return pivotDataSource;
}
}Options are inputs, bound with [name]="value".
Events are outputs named on plus the event name with a capital first letter. For example, pivotitemexpanding: This event is triggered when a pivot item is expanding.
<jqxPivotGrid (onPivotitemexpanding)="onPivotitemexpanding($event)"></jqxPivotGrid>
onPivotitemexpanding(event: any): void {
console.log(event.args);
}
Get the component with a signal query and call its methods. For example, refresh: Refreshes the content of the pivot grid component
<jqxPivotGrid #myPivotGrid></jqxPivotGrid>
import { Component, viewChild } from '@angular/core';
import { jqxPivotGridModule, jqxPivotGridComponent } from 'jqwidgets-ng/jqxpivotgrid';
@Component({
selector: 'app-root',
imports: [jqxPivotGridModule],
templateUrl: './app.html'
})
export class App {
readonly myPivotGrid = viewChild.required<jqxPivotGridComponent>('myPivotGrid');
run(): void {
this.myPivotGrid().refresh();
}
}