Remove aggrigation type on pdfexcel export


            <ejs-grid id="GrdRevenueList" dataSource="@ViewBag.RevenueMasterlists" allowPaging="true" showColumnChooser="true" actionComplete="onActionComplete" allowResizing="true" gridLines="Both" allowFiltering="true" height="100%" width="auto" enableHover="true" allowExcelExport="true" toolbar="@(new List<string>() {"ColumnChooser","ExcelExport"})" toolbarClick="toolbarClick" actionBegin="actionBegin" dataBound="dataBound">

                <e-grid-filterSettings type="Excel"></e-grid-filterSettings>

                <e-grid-pageSettings pageCount="5" pageSize="100" />

                <e-grid-columns>

                    <e-grid-column headerText="Edit" width="80" template="#template-edit" textAlign="Center"></e-grid-column>

                    <e-grid-column headerText="View" width="80" template="#template-view" textAlign="Center"></e-grid-column>

                    <e-grid-column field="ID" showInColumnChooser="false" headerText="ID" lockColumn="true" visible="false"></e-grid-column>

                    <e-grid-column field="ServiceIDStatus" headertext="Service ID Status" width="140" textAlign="Left"></e-grid-column>

                    <e-grid-column field="ServiceIDShort" headertext="Service ID Short" width="140" textAlign="Left"></e-grid-column>

                    <e-grid-column field="ServiceID" headertext="ServiceID" width="140" textAlign="Left"></e-grid-column>

                    <e-grid-column field="TotalDocumentvalue" headertext="Total Document value" width="140" textAlign="Left" type="number" format="N2"></e-grid-column>

                    <e-grid-column field="ActualVolumeOct" headertext="Actual Volume Oct" width="140" textAlign="Left" type="number" format="N2"></e-grid-column>

                    <e-grid-column field="ActualVolumeNov" headertext="Actual Volume Nov" width="140" textAlign="Left" type="number" format="N2"></e-grid-column>

--- More Columns---

                </e-grid-columns>

<e-grid-aggregates>

<e-grid-aggregate>

<e-aggregate-columns>

<e-aggregate-column field="TotalDocumentvalue" type="Sum" footerTemplate="Total: ${Sum}" format="N2"></e-aggregate-column>

<e-aggregate-column field="ActualVolumeOct" type="Sum" footerTemplate="Total: ${Sum}" format="N2"></e-aggregate-column>

<e-aggregate-column field="ActualVolumeNov" type="Sum" footerTemplate="Total: ${Sum}" format="N2"></e-aggregate-column>

</e-aggregate-columns>

</e-grid-aggregate>

</e-grid-aggregates>

            </ejs-grid>

on excel export Aggregate row are also getting downloaded how can we avoid that


1 Reply

JC Joseph Christ Nithin Issack Syncfusion Team March 15, 2024 10:44 AM UTC


Hi Richie,


  Greetings from Syncfusion.


   Based on your query, you want to remove the aggregates row, while exporting to Excel file or to Pdf File. Your requirement can be achieved using the ‘beforeExcelExport’ and ‘beforePdfExport’ event of the EJ2 Grid. In this event, we have set ‘args.gridObject.aggregates’ as null.


Please refer the below code example:


 

 

 

<div class="control-section">

    <div class="col-lg-6">

        <ejs-grid id="Grid" dataSource="@ViewBag.DataSource" created="created" allowSorting="true" allowPaging="true" allowPdfExport="true" allowExcelExport="true" toolbar="@(new List<string>() {"ExcelExport", "PdfExport", "CsvExport" })" toolbarClick="toolbarClick" beforeExcelExport="beforeExcelExport" beforePdfExport="beforePdfExport">

            <e-grid-columns>

                --------------------------------

                --------------------------------

                --------------------------------

           </e-grid-columns>

            <e-grid-aggregates>

                <e-grid-aggregate>

                    <e-aggregate-columns>

                        <e-aggregate-column field="Freight" type="Sum" format="C2" footerTemplate="Sum:${Sum}"></e-aggregate-column>

                    </e-aggregate-columns>

                </e-grid-aggregate>

                <e-grid-aggregate>

                    <e-aggregate-columns>

                        <e-aggregate-column field="Freight" type="Average" format="C2" footerTemplate="Average:${Average}"></e-aggregate-column>

                    </e-aggregate-columns>

                </e-grid-aggregate>

            </e-grid-aggregates>

        </ejs-grid>

 

    </div>

</div>

 

 

<script>

    var grid;

 

    function created() {

        grid = document.getElementById('Grid').ej2_instances[0];

    }

 

   function toolbarClick(args) {

        if (args.item.id === 'Grid_pdfexport') {

            grid.pdfExport();

        }

        if (args.item.id === 'Grid_excelexport') {

            grid.excelExport();

        }

    };

 

    function beforePdfExport(args) {

       args.gridObject.aggregates = null;

    }

 

 

    function beforeExcelExport(args) {

        args.gridObject.aggregates = null;

    }

 

</script>


Regards,

Joseph I.




Loader.
Up arrow icon