How can I help you?
Defer update in ASP.NET Core Pivot Table component
26 Feb 20266 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 in ejs-pivotview as true. Note that the defer update option can be controlled only via Field List during runtime.
<ejs-pivotview id="PivotView" height="300" showFieldList="true" allowDeferLayoutUpdate="true">
<e-datasourcesettings dataSource="@ViewBag.DataSource" expandAll="false" enableSorting="true">
<e-formatsettings>
<e-field name="Amount" format="C0" maximumSignificantDigits="10" minimumSignificantDigits="1" useGrouping="true"></e-field>
</e-formatsettings>
<e-rows>
<e-field name="Country"></e-field>
<e-field name="Products"></e-field>
</e-rows>
<e-columns>
<e-field name="Year" caption="Year"></e-field>
<e-field name="Quarter"></e-field>
</e-columns>
<e-values>
<e-field name="Sold" caption="Units Sold"></e-field>
<e-field name="Amount" caption="Sold Amount"></e-field>
</e-values>
</e-datasourcesettings>
</ejs-pivotview>public ActionResult Index()
{
var data = GetPivotData();
ViewBag.DataSource = data;
return View();
}
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 e-pivotfieldlist.
To enable deferred updates in the static fieldlist, set the allowDeferLayoutUpdate in e-pivotfieldlist as true. 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.
<ejs-pivotview id="PivotView" enginePopulated="onGridEnginePopulate" height="300" allowDeferLayoutUpdate="true"></ejs-pivotview>
<br />
<ejs-pivotfieldlist id="Static_FieldList" renderMode="Fixed" allowDeferLayoutUpdate="true" enginePopulated="onFieldListEnginePopulate">
<e-datasourcesettings dataSource="@ViewBag.DataSource" expandAll="false" enableSorting="true">
<e-fieldlist-formatsettings>
<e-field name="Amount" format="C0" maximumSignificantDigits="10" minimumSignificantDigits="1" useGrouping="true"></e-field>
</e-fieldlist-formatsettings>
<e-fieldlist-rows>
<e-field name="Country"></e-field>
<e-field name="Products"></e-field>
</e-fieldlist-rows>
<e-fieldlist-columns>
<e-field name="Year" caption="Year"></e-field>
<e-field name="Quarter"></e-field>
</e-fieldlist-columns>
<e-fieldlist-values>
<e-field name="Sold" caption="Units Sold"></e-field>
<e-field name="Amount" caption="Sold Amount"></e-field>
</e-fieldlist-values>
</e-datasourcesettings>
</ejs-pivotfieldlist>
<style>
#Static_FieldList {
width: 400px;
}
</style>
<script>
var pivotObj; var fieldlistObj;
function onGridEnginePopulate(args) {
pivotObj = document.getElementById('PivotView').ej2_instances[0];
fieldlistObj = document.getElementById('PivotFieldList').ej2_instances[0];
if (fieldlistObj) {
fieldlistObj.update(pivotObj);
}
}
function onFieldListEnginePopulate(args) {
pivotObj = document.getElementById('PivotView').ej2_instances[0];
fieldlistObj = document.getElementById('PivotFieldList').ej2_instances[0];
if (fieldlistObj.isRequiredUpdate) {
fieldlistObj.updateView(pivotObj);
}
pivotObj.notify('ui-update', pivotObj);
fieldlistObj.notify('tree-view-update', fieldlistObj);
}
</script>public ActionResult Index()
{
var data = GetPivotData();
ViewBag.DataSource = data;
return View();
}