We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Max lines pdf and excel grid export

Hello,

How can I define a maximum number of grid lines to export to PDF and Excel files? I'm using AllowPaging="true" and ODataV2Adaptor in the grid.

Thanks,

Erick


1 Reply

NP Naveen Palanivel Syncfusion Team March 30, 2023 09:07 PM UTC

Hi Erick,


We checked your query and we have already discussed about this  similar topics detailly in our UG documentation. Kindly refer the documentation link shared.


Link : https://blazor.syncfusion.com/documentation/datagrid/pdf-export#custom-data-source

              https://blazor.syncfusion.com/documentation/datagrid/excel-exporting#custom-data-source


private SfGrid<Order> DefaultGrid;

    public List<Order> Orders { get; set; }

 

    public async Task ToolbarClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args)

    {

        if (args.Item.Id == "Grid_pdfexport"//Id is combination of Grid's ID and itemname

        {

            PdfExportProperties PdfProperties = new PdfExportProperties();

            PdfProperties.DataSource = Orders.Take(10).ToList();  //Here you can customize your count

            await this.DefaultGrid.PdfExport(PdfProperties);

        }

    }

    protected override void OnInitialized()

    {

        Orders = Enumerable.Range(1, 75).Select(x => new Order()

            {

                OrderID = 1000 + x,

                CustomerID = (new string[] { "ALFKI", "ANANTR", "ANTON", "BLONP", "BOLID" })[new Random().Next(5)],

                Freight = 2.1 * x,

                OrderDate = DateTime.Now.AddDays(-x),

            }).ToList();

    }

 



Please let us know if you have any concerns.


Regards,

Naveen Palanivel


Loader.
Live Chat Icon For mobile
Up arrow icon