Progress® Telerik® Reporting R3 2019

How to: Implement a report definition storage

This article describes how to use the Web Report Designer to design reports which are stored in a custom storage location. Out-of-the-box we provide a FileDefinitionStorage which is configured to use the file system. To open reports stored in a different manner you need to implement the IDefinitionStorage interface. This will enable the web designer to load reports from a custom location such as a database, cloud, in-memory, etc.

Implement Custom Storage

The purpose of the report definition storage is to describe how to browse, open, save, and delete reports from the Web Report Designer. The storage is configured as a setting of the ReportDesignerController.

C#
public ReportDesignerController(ConfigurationService configSvc)
{
    ...

    this.ReportDesignerServiceConfiguration = new ReportDesignerServiceConfiguration
    {
        DefinitionStorage = new FileDefinitionStorage(this.reportsPath)
    };
}

The default implementation of the storage demonstrated above is the FileDefinitionStorage. It provides functionality for working with TRDP/TRDX report files stored on the server-side file system. To load the reports from a database, for example, change the implementation of the definition storage like this:

C#
public class DbDefinitionStorage : IDefinitionStorage
{
    /// <summary>
    /// Lists all report definitions.
    /// </summary>
    /// <returns>A list of all report definitions present in the storage.</returns>
    public IEnumerable<string> ListDefinitions()
    {
        // Retrieve all available reports in the database and return their unique identifiers.
    }

    /// <summary>
    /// Finds a report definition by its id.
    /// </summary>
    /// <param name="definitionId">The report definition identifier.</param>
    /// <returns>The bytes of the report definition.</returns>
    public byte[] GetDefinition(string definitionId)
    {
        // Retrieve the report definition bytes from the database.
    }

    /// <summary>
    /// Creates new or overwrites an existing report definition with the provided definition bytes.
    /// </summary>
    /// <param name="definitionId">The report definition identifier.</param>
    /// <param name="definition">The new bytes of the report definition.</param>
    public void SaveDefinition(string definitionId, byte[] definition)
    {
        // Save the report definiton bytes to the database.
    }

    /// <summary>
    /// Deletes an existing report definition.
    /// </summary>
    /// <param name="definitionId">The report definition identifier.</param>
    public void DeleteDefinition(string definitionId)
    {
        // Delete the report definition from the database.
    }
}

Then you can set the new definition storage implementation in the ReportDesignerController.

C#
public ReportDesignerController(ConfigurationService configSvc)
{
    ...

    this.ReportDesignerServiceConfiguration = new ReportDesignerServiceConfiguration
    {
        DefinitionStorage = new DbDefinitionStorage()
    };
}
In this article
Not finding the help you need?