Export grid to excel not working

Hi the following is not working, I am sure I am missing something very simple?
Nothing happens when i click the tool bar button. No errors, no action nothing.
It does not even reach the console.writeline in the method handler


<SfGrid ID="MyGrid" @ref="sfGridRef" TValue="MyDto" AllowPaging="true" AllowFiltering="true"
  AllowSorting="false" Toolbar="@(new List<string>() { "ExcelExport" })" AllowExcelExport="true">
  <GridEvents OnToolbarClick="ToolbarClickHandler" TValue="MyDto"></GridEvents>
  <SfDataManager
      Url=@($"api/{SD.ApiVersion}/reports/odata/letters?year={Year}&clerkname={ClerkName}&clerkposition={ClerkPosition}")
      Adaptor="Syncfusion.Blazor.Adaptors.WebApiAdaptor" HttpClientInstance=@(_hc.CreateClient("MyApp"))>
  </SfDataManager>
  <GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Menu" />
  <GridPageSettings PageSize="@SD.paginationDefaultSize" PageCount="5" PageSizes="true" />
  <GridEditSettings />
  <GridEvents OnActionFailure="OnGridActionFailure" TValue="MyDto" />
  <GridColumns>
      <GridColumn Field=@nameof(MyDto.Col1) HeaderText="Col 1" AllowFiltering="false" />
      <GridColumn Field=@nameof(MyDto.Col2) HeaderText="Col 2" />
      <GridColumn Field=@nameof(MyDto.Col3) HeaderText="Col 3" Format="C2" />
  </GridColumns>
</SfGrid>


@code {
private SfGrid<MyDto>? sfGridRef;


private async Task ToolbarClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args)
{
Console.WriteLine($"*** {args.Item.Id}");
if (args.Item.Id == "MyGrid_excelexport") //Id is combination of Grid's ID and itemname
{
ExcelExportProperties ExcelProperties = new ExcelExportProperties();
ExcelProperties.FileName = $"letters-{DateTime.UtcNow.ToString()}.csv";
if (sfGridRef is not null) await sfGridRef.ExportToCsvAsync(ExcelProperties);
}
}
}




2 Replies

WW Wuss Wuzz April 20, 2024 07:58 PM UTC

Ok i saw I had two gridevent tags.  After combining them I was able to download the file.  

I ran into another problem.  It only downloads the first page instead of all the records.



VN Vignesh Natarajan Syncfusion Team April 22, 2024 10:07 AM UTC

Hi Wuss,


Thanks for the update,

We are happy to hear that the issue you reported has been resolved at your end. However, you have encountered another problem 'It only downloads the first page instead of all the records.' We are unable to reproduce the reported issue when attempting to do so in the latest version 25.1.40.So, to further proceed with the reporting problem, we require some additional clarification from your end. Please share the below details to proceed further at our end.


  • To analyze the reported issue, could you please share a simple and reproducible sample with duplicate data that demonstrates the problem? This will assist us in identifying the issue more efficiently and providing a resolution.
  • Could you please share us the what the NuGet version you have used?
  • If possible, please share your attempt to replicate the issue along with the attached sample below.

The details requested above will be very helpful in validating the reported query on our end and providing a solution as soon as possible. Thanks for your understanding.

Note: After connecting the database we need to copy the path of the database and change the connectionstring with the copied path in OrderContext.cs file based on the NORTHWND.MDF file in APP_Data folder.

Regards,
Vignesh Natarajan


Attachment: DatagridWithWebapiSample_7763428b.zip

Loader.
Up arrow icon