Having trouble getting help?
Contact Support
Contact Support
Export table and chart into the same document using toolbar
4 Aug 20232 minutes to read
Even if the e-displayOption.view
property is set to Both in the pivot table, you can only export either the table or the chart to the PDF document based on the current value set in the e-displayOption.primary
property. But, to export both the table and the chart to the same PDF document, use the pdfExport
method during the actionBegin
event invoke.
In the following example, the built-in export action can be restricted by setting the args.cancel
option to true in the actionBegin
event, and both the table and the chart can be exported by calling the pdfExport
method and setting the exportBothTableAndChart
argument to true.
<ejs-pivotview id="pivotview" height="300" actionBegin="actionBegin" showToolbar="true"
toolbar="@(new List<string>() { "Grid", "Chart", "Export", "FieldList" })" allowPdfExport="true" showFieldList="true">
<e-datasourcesettings dataSource="@ViewBag.DataSource" expandAll="false">
<e-formatsettings>
<e-field name="Amount" format="C0"></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>
<e-displayOption view="Both"></e-displayOption>
</ejs-pivotview>
<script>
function actionBegin(args) {
var pivotTableObj = document.getElementById('pivotview').ej2_instances[0];
if (args.actionName == 'PDF export') {
args.cancel = true;
pivotTableObj.pdfExport({}, false, null, false, true);
}
}
</script>
public ActionResult Index()
{
var data = GetPivotData();
ViewBag.DataSource = data;
return View();
}