How to Export Data from a Radzen DataGrid

(1) How do you export data from a Radzen DataGrid, in which IEnumerable Rows are filled from the result of a REST API Query?

(2) How to possibly search the data in the DataGrid?

-> Are their any relevant examples?

You can turn on both search and export when you scaffold/create pages in Radzen IDE.

    protected async Task Search(ChangeEventArgs args)
    {
        search = $"{args.Value}";

        await grid0.GoToPage(0);

        await grid0.Reload();
    }

and

    protected async Task ExportClick(RadzenSplitButtonItem args)
    {
       //TODO: Export getNewOrders
    }

respectively.

Are there any examples that I might look at?

You have two options:

  • Get all data and filter/search in-memory
  • Use REST API to search/filter if available

For export you will need to get all data and pass it to the export method(s).

Are there any examples? The only ones that I can see target database data from a DB Connection directly and not from a REST API.

There are not examples with REST API.

Could you guys make a simple one using your YouTube Video entitled How to "Consume REST APIs in your Blazor Apps" for the GetNewReleases Method?

I'm new at OData and would appreciate some assistance.

Hi @FastTrak,

All you need to do is to retrieve your data server side when the export method is called:

var result = await YourService.YourMethod();

and pass the result to ToCSV() or ToExcel() methods from our example:

The steps are:

  1. Navigate to specific controller where the exporting will be made:
    radzen-blazor/RadzenBlazorDemos/Services/NorthwindService.cs at master · radzenhq/radzen-blazor · GitHub

  2. Export data:
    radzen-blazor/RadzenBlazorDemos.Host/Controllers/ExportNorthwindController.cs at master · radzenhq/radzen-blazor · GitHub

I looked over the example and am quite perplexed about implementing it. I am using your Blazor Web Application Template using dot Net 8. The Example deals with a Northwind Db Connection and not a REST Web API connection. Can you give a bit more of a hint, please?

It’s the same in our demos.

It doesn’t matter where the data are coming from, I already explained the steps in my previous reply.