Back to Devexpress

JSON Data - Change Data Source at Runtime

xtrareports-402555-web-reporting-asp-net-core-reporting-end-user-report-designer-in-asp-net-applications-use-data-sources-and-connections-json-data-change-data-source-at-runtime.md

latest1.2 KB
Original Source

JSON Data - Change Data Source at Runtime

  • Aug 18, 2023

When a JSON data source is already registered in the End-User Report Designer in ASP.NET Core Applications, you cannot change the data source’s JsonSource property to load data from another endpoint: the data may already be loaded and cached. To specify a new JSON source, implement the IJsonSourceCustomizationService interface.

csharp
using DevExpress.XtraPrinting.Native;

// ...
XtraReport1 report = new XtraReport1();
report.ReplaceService<IJsonSourceCustomizationService>(new MyJsonCustomizationService()); 
report.CreateDocument();

public class MyJsonCustomizationService : IJsonSourceCustomizationService  
{  
    public JsonSourceBase CustomizeJsonSource(JsonDataSource jsonDataSource)  
    {  
        return new DevExpress.DataAccess.Json.UriJsonSource("https://northwind.netcore.io/customers.json"));  
    }  
}