Vue UI Components Documentation
The Vue PivotGrid displays summarized data in a multi-dimensional, cross-tabulated view. This guide adds the Vue PivotGrid (jqxPivotGrid) to an app, then shows how to set its options, handle its events and call its methods.
jqwidgets-scriptsjqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue 
In a Vue 3 project (to start one, see Getting started with Vue), add the package:
npm install jqwidgets-scripts
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
import 'jqwidgets-scripts/jqwidgets/styles/jqx.base.css';
import 'jqwidgets-scripts/jqwidgets/styles/jqx.tailwind-blue-dark.css';
With <script setup>, an imported component is ready to use in the template. jqx.base.css is required; the second file is a theme, selected with the theme attribute.
The Pivot Grid Cell Values Alignment demo as a Single-File Component:
<template>
<JqxPivotGrid
:source="pivotDataSource"
:treeStyleRows="true"
:autoResize="true"
:multipleSelectionEnabled="true"
>
</JqxPivotGrid>
</template>
<script setup>
import { ref } from 'vue';
import JqxPivotGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxpivotgrid.vue';
const pivotDataSource = ref();
const createPivotDataSource = function () {
// 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 = {};
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;
};
pivotDataSource.value = createPivotDataSource();
</script>Options are attributes. Bind values from the script with :, for example :width="850".
Listen to an event with @ and its name. For example, pivotitemexpanding: This event is triggered when a pivot item is expanding.
<script setup>
function onPivotitemexpanding(event) {
console.log(event.args);
}
</script>
<template>
<JqxPivotGrid @pivotitemexpanding="onPivotitemexpanding" />
</template>
Call methods through a template ref. For example, refresh: Refreshes the content of the pivot grid component
<script setup>
import { ref, onMounted } from 'vue';
const myPivotGrid = ref(null);
onMounted(() => {
myPivotGrid.value.refresh();
});
</script>
<template>
<JqxPivotGrid ref="myPivotGrid" />
</template>
Every component also has setOptions({ … }) and getOptions('name').