Hide empty headers in the Vue Pivot Table component
When the raw data for a particular field is not defined, it will be shown as ‘Undefined’ in the pivot table headers. You can hide those headers by setting the showHeaderWhenEmpty property to false in the pivot table.
For example, when the raw data contains “United Kingdom” for the ‘Country’ field but the “State” field is undefined, the header displays as “United Kingdom » Undefined”. Here, you can hide those ‘Undefined’ headers using the showHeaderWhenEmpty property.
By default, this property is set to true.
<template>
<div id="app">
<ejs-pivotview :dataSourceSettings="dataSourceSettings" :height="height" :showFieldList="showFieldList">
</ejs-pivotview>
</div>
</template>
<script setup>
import { provide } from "vue";
import { PivotViewComponent as EjsPivotview, FieldList } from "@syncfusion/ej2-vue-pivotview";
import { pivotNullData } from './pivotNullData.js';
const dataSourceSettings = {
dataSource: pivotNullData,
expandAll: false,
rows: [{ name: 'Country' }, { name: 'State' }],
columns: [{ name: 'Product', showNoDataItems: true }, { name: 'Date' }],
values: [{ name: 'Amount' }, { name: 'Quantity' }],
showHeaderWhenEmpty: false
};
const height = 350;
const showFieldList = true;
provide('pivotview', [FieldList]);
</script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-pivotview/styles/tailwind3.css";
</style><template>
<div id="app">
<ejs-pivotview :dataSourceSettings="dataSourceSettings" :height="height" :showFieldList="showFieldList">
</ejs-pivotview>
</div>
</template>
<script>
import { PivotViewComponent, FieldList } from "@syncfusion/ej2-vue-pivotview";
import { pivotNullData } from './pivotNullData.js';
export default {
name: "App",
components: {
"ejs-pivotview": PivotViewComponent
},
data() {
return {
dataSourceSettings: {
dataSource: pivotNullData,
expandAll: false,
rows: [{ name: 'Country' }, { name: 'State' }],
columns: [{ name: 'Product', showNoDataItems: true }, { name: 'Date' }],
values: [{ name: 'Amount' }, { name: 'Quantity' }],
showHeaderWhenEmpty: false
},
height: 350,
showFieldList: true
}
},
provide: {
pivotview: [FieldList]
}
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-pivotview/styles/tailwind3.css";
</style>