Search results

Exporting Filtered Data Only

You can export the filtered data by defining the resulted data in exportProperties.dataSource before export.

In the below Pdf exporting demo, We have gotten the filtered data by applying filter query to the grid data and then defines the resulted data in exportProperties.dataSource and pass it to pdfExport method.

<ejs-grid id="Grid" dataSource="@ViewBag.DataSource" allowPdfExport="true" toolbarClick="toolbarClick" toolbar="@(new List<string>() {"PdfExport"})"
 allowPaging="true" allowFiltering="true"> 
<e-grid-pagesettings pageCount="5" pageSize="5"></e-grid-pagesettings>
        <e-grid-column field="OrderID" headerText="Order ID" textAlign="Right" width="120"></e-grid-column>
        <e-grid-column field="CustomerID" headerText="Customer ID" width="150"></e-grid-column>
        <e-grid-column field="ShipCity" headerText="Ship City" width="150"></e-grid-column>
        <e-grid-column field="ShipName" headerText="Ship Name" width="150"></e-grid-column>
    function toolbarClick(args) {
        var gridObj = document.getElementById("Grid").ej2_instances[0];
        if ( === 'Grid_pdfexport') {
            var pdfdata;
            var query =; // get grid corresponding query  
            for (var i = 0; i < query.queries.length; i++) {
                if (query.queries[i].fn == 'onPage') {
                    query.queries.splice(i, 1);     // remove page query to get all records
            var data = @Html.Raw(Json.Serialize(ViewBag.DataSource));
            var fdata = new{ json: data }).executeQuery(query).then((e) => {
                pdfdata = e.result;   // get all filtered records
                var exportProperties = {
                    dataSource: pdfdata,
            }).catch((e) => true);
public IActionResult Index()
    ViewBag.DataSource = OrderDetails.GetAllRecords();
    return View();