Search results

Passing additional parameters to the server when Exporting in ASP.NET Core Grid control

20 Oct 2021 / 1 minute to read

You can pass the additional parameter in the query property by invoking addParams method. In the toolbarClick event, you can define params as key and value pair so it will receive at the server side when exporting.

In the below example, we have passed recordcount as 12 using addParams method.

Copied to clipboard
<ejs-grid id="Grid" dataSource="@ViewBag.DataSource" allowPdfExport="true" allowExcelExport="true" toolbarClick="toolbarClick" pdfExportComplete="pdfExportComplete" excelExportComplete="excelExportComplete" toolbar="@(new List<string>() {"PdfExport", "ExcelExport"})" allowPaging="true">
        <e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true" textAlign="Right" width="120"></e-grid-column>
        <e-grid-column field="CustomerID" headerText="Customer ID" visible="false" width="140"></e-grid-column>
        <e-grid-column field="Freight" headerText="Freight" textAlign="Right" format="C2" width="120"></e-grid-column>
        <e-grid-column field="OrderDate" headerText="Order Date" width="140" format="yMd"></e-grid-column>

    var queryClone;
    function toolbarClick(args) {
        var gridObj = document.getElementById("Grid").ej2_instances[0];
        if ( === 'Grid_pdfexport') {
            queryClone = gridObj.query;
            gridObj.query = new"recordcount", "12");
        else if ( === 'Grid_excelexport') {
            queryClone = gridObj.query;
            gridObj.query = new"recordcount", "12");
    function pdfExportComplete(args) {
        this.query = queryClone;
    function excelExportComplete(args) {
        this.query = queryClone;