Defer update in Vue Pivot Table component
22 Jan 202610 minutes to read
Defer layout update support allows updating the pivot table component only on demand, significantly improving performance for complex data operations. When this feature is enabled, users can drag-and-drop fields between row, column, value, and filter axes, apply sorting and filtering inside the Field List, resulting in changes to the pivot report configuration without immediately updating the pivot table values. Once all operations are performed and the “Apply” button is clicked in the Field List, the pivot table will update with the final modified report. This approach reduces multiple unnecessary renders and brings better performance, especially when working with large datasets or performing multiple field operations.
The field list can be displayed in two different formats to interact with the pivot table:
- In-built Field List (Popup): Displays the field list icon in the pivot table UI to invoke the built-in dialog.
- Stand-alone Field List (Fixed): Displays the field list in a static position within a web page.
In-built Field List (Popup)
To enable deferred updates in the pivot table, set the allowDeferLayoutUpdate property to true in PivotView. Note that the defer update option can be controlled only via Field List during runtime.
<template>
<div id="app">
<ejs-pivotview :dataSourceSettings="dataSourceSettings" :height="height" :showFieldList="showFieldList"
:allowDeferLayoutUpdate="allowDeferLayoutUpdate"> </ejs-pivotview>
</div>
</template>
<script setup>
import { provide } from "vue";
import { PivotViewComponent as EjsPivotview, FieldList } from "@syncfusion/ej2-vue-pivotview";
import { pivotData } from './pivotData.js';
const dataSourceSettings = {
dataSource: pivotData,
expandAll: false,
allowLabelFilter: true,
allowValueFilter: true,
drilledMembers: [{ name: 'Country', items: ['France'] }],
columns: [{ name: 'Year', caption: 'Production Year' }, { name: 'Quarter' }],
values: [{ name: 'Sold', caption: 'Units Sold' }, { name: 'Amount', caption: 'Sold Amount' }],
rows: [{ name: 'Country' }, { name: 'Products' }],
formatSettings: [{ name: 'Amount', format: 'C0' }],
filters: []
};
const height = 350;
const showFieldList = true;
const allowDeferLayoutUpdate = 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"
:allowDeferLayoutUpdate="allowDeferLayoutUpdate"> </ejs-pivotview>
</div>
</template>
<script>
import { PivotViewComponent, FieldList } from "@syncfusion/ej2-vue-pivotview";
import { pivotData } from './pivotData.js';
export default {
name: "App",
components: {
"ejs-pivotview": PivotViewComponent
},
data() {
return {
dataSourceSettings: {
dataSource: pivotData,
expandAll: false,
allowLabelFilter: true,
allowValueFilter: true,
drilledMembers: [{ name: 'Country', items: ['France'] }],
columns: [{ name: 'Year', caption: 'Production Year' }, { name: 'Quarter' }],
values: [{ name: 'Sold', caption: 'Units Sold' }, { name: 'Amount', caption: 'Sold Amount' }],
rows: [{ name: 'Country' }, { name: 'Products' }],
formatSettings: [{ name: 'Amount', format: 'C0' }],
filters: []
},
height: 350,
showFieldList: true,
allowDeferLayoutUpdate: true
}
},
provide: {
pivotview: [FieldList]
}
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-pivotview/styles/tailwind3.css";
</style>Stand-alone Field List (Fixed)
The field list can be rendered in a static position anywhere in the web page layout, functioning as a separate component. To achieve this, set the renderMode property to Fixed in PivotFieldList.
To enable deferred updates in the static fieldlist, set the allowDeferLayoutUpdate property to true in PivotFieldList. Note that the defer update option can be controlled only via Field List during runtime.
To make the field list interact with the pivot table, use the updateView and update methods to synchronize data source updates between both the field list and pivot table components simultaneously.
<template>
<div id="app">
<ejs-pivotview id="pivotview_flist" :height="height" :allowDeferLayoutUpdate="allowDeferLayoutUpdate"></ejs-pivotview>
<ejs-pivotfieldlist id="pivotfieldlist1" :allowDeferLayoutUpdate="allowDeferLayoutUpdate"
:dataSourceSettings="dataSourceSettings" :enginePopulated="fieldEnginePopulated"
:renderMode="renderMode"></ejs-pivotfieldlist>
</div>
</template>
<script setup>
import { PivotViewComponent as EjsPivotview, PivotFieldListComponent as EjsPivotfieldlist } from "@syncfusion/ej2-vue-pivotview";
import { pivotData } from './pivotData.js';
const dataSourceSettings = {
dataSource: pivotData,
expandAll: false,
columns: [{ name: 'Year', caption: 'Production Year' }, { name: 'Quarter' }],
values: [{ name: 'Sold', caption: 'Units Sold' }, { name: 'Amount', caption: 'Sold Amount' }],
rows: [{ name: 'Country' }, { name: 'Products' }],
formatSettings: [{ name: 'Amount', format: 'C0' }],
filters: []
};
const height = 350;
const renderMode = "Fixed";
const allowDeferLayoutUpdate = true;
const fieldEnginePopulated = () => {
let fieldlistObj = document.getElementById('pivotfieldlist1').ej2_instances[0];
let pivotGridObj = document.getElementById('pivotview_flist').ej2_instances[0];
if (fieldlistObj.isRequiredUpdate) {
fieldlistObj.updateView(pivotGridObj);
}
pivotGridObj.notify('ui-update', pivotGridObj);
fieldlistObj.notify('tree-view-update', fieldlistObj);
};
</script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-pivotview/styles/tailwind3.css";
#pivotfieldlist1 {
width: 400px;
margin-top: 20px;
}
</style><template>
<div id="app">
<ejs-pivotview id="pivotview_flist" :height="height" :allowDeferLayoutUpdate="allowDeferLayoutUpdate"></ejs-pivotview>
<ejs-pivotfieldlist id="pivotfieldlist1" :allowDeferLayoutUpdate="allowDeferLayoutUpdate"
:dataSourceSettings="dataSourceSettings" :enginePopulated="fieldEnginePopulated"
:renderMode="renderMode"></ejs-pivotfieldlist>
</div>
</template>
<script>
import { PivotViewComponent, PivotFieldListComponent } from "@syncfusion/ej2-vue-pivotview";
import { pivotData } from './pivotData.js';
export default {
name: "App",
components: {
"ejs-pivotview": PivotViewComponent,
"ejs-pivotfieldlist": PivotFieldListComponent
},
data() {
return {
dataSourceSettings: {
dataSource: pivotData,
expandAll: false,
columns: [{ name: 'Year', caption: 'Production Year' }, { name: 'Quarter' }],
values: [{ name: 'Sold', caption: 'Units Sold' }, { name: 'Amount', caption: 'Sold Amount' }],
rows: [{ name: 'Country' }, { name: 'Products' }],
formatSettings: [{ name: 'Amount', format: 'C0' }],
filters: []
},
height: 350,
renderMode: "Fixed",
allowDeferLayoutUpdate: true
}
},
methods: {
fieldEnginePopulated: function (args) {
let fieldlistObj = document.getElementById('pivotfieldlist1').ej2_instances[0];
let pivotGridObj = document.getElementById('pivotview_flist').ej2_instances[0];
if (fieldlistObj.isRequiredUpdate) {
fieldlistObj.updateView(pivotGridObj);
}
pivotGridObj.notify('ui-update', pivotGridObj);
fieldlistObj.notify('tree-view-update', fieldlistObj);
}
}
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-vue-pivotview/styles/tailwind3.css";
#pivotfieldlist1 {
width: 400px;
margin-top: 20px;
}</style>