Answer:
It seems you didn’t set the grid reference in the SfGrid component. Find the below code snippet and the sample to resolve your reference.
<SfGrid @ref="MainGrid_locations" DataSource="@Orders" Toolbar="@( new List<string>() { "ColumnChooser", "Search", "ExcelExport", "PdfExport"})"> <GridEvents OnToolbarClick="ToolbarClickHandler" TValue="Order">GridEvents> <GridPageSettings PageSize="5">GridPageSettings> <GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Menu">GridFilterSettings> <GridPageSettings PageCount="1" PageSizes="true">GridPageSettings> public SfGrid MainGrid_locations { get; set; } //You can set async void instead of void/async Task public async void ToolbarClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args) { if (args.Item.Text == "Excel Export") //Since it is asynchronous function use await await this.MainGrid_locations.ExcelExport(); if (args.Item.Text == "PDF Export") await this.MainGrid_locations.PdfExport(); |
You can get the sample for Excel and PDF export using Toolbar functions from
here.