Progress® Telerik® Reporting R1 2021

New to Telerik Reporting? Download free 30-day trial

How to Implement a Custom Report Source Resolver

This article explains how to create a custom report source resolver for the Telerik Reporting REST service. In this example, the resolver purpose will be to return a XmlReportSource with an XML report definition obtained from an SQL Server database.

How to implement a custom report source resolver:

  1. Create a class which implements the IReportSourceResolver interface. Its Resolve(String, OperationOrigin, IDictionaryString, Object) method will be called whenever the engine needs to create a ReportSource instance based on the parameter named report. The value of the report parameter will be initialized with the value of the Report property of the report viewer's ReportSource object.

    class CustomReportSourceResolver : IReportSourceResolver
        public Telerik.Reporting.ReportSource Resolve(string reportId, OperationOrigin operationOrigin, IDictionary<string, object> currentParameterValues)
            var cmdText = "SELECT Definition FROM Reports WHERE ID = @ReportId";
            var reportXml = string.Empty;
            using (var conn = new System.Data.SqlClient.SqlConnection(@"server=(local)\sqlexpress;database=REPORTS;integrated security=true;"))
                var command = new System.Data.SqlClient.SqlCommand(cmdText, conn);
                command.Parameters.Add("@ReportId", System.Data.SqlDbType.Int);
                command.Parameters["@ReportId"].Value = reportId;
                    reportXml = (string)command.ExecuteScalar();
                catch (System.Exception ex)
            if (string.IsNullOrEmpty(reportXml))
                throw new System.Exception("Unable to load a report with the specified ID: " + reportId);
            return new Telerik.Reporting.XmlReportSource { Xml = reportXml };
  2. Find the ReportSourceResolver property in the ReportServiceConfiguration settings of the implementation of the ReportsControllerBase class, and set it to an instance of the custom report source resolver or to a chain of resolver instances including the custom one:

    public class CustomResolverReportsController : ReportsControllerBase
        static ReportServiceConfiguration configurationInstance;
        static CustomResolverReportsController()
            var resolver = new UriReportSourceResolver(HttpContext.Current.Server.MapPath("~/Reports"))
                .AddFallbackResolver(new TypeReportSourceResolver()
                    .AddFallbackResolver(new CustomReportSourceResolver()));
            configurationInstance = new ReportServiceConfiguration
                HostAppId = "Application1",
                ReportSourceResolver = resolver,
                Storage = new Telerik.Reporting.Cache.File.FileStorage(),
        public CustomResolverReportsController()
            this.ReportServiceConfiguration = configurationInstance;
  3. Request the report from the HTML5 Report Viewer on the client:

    <script type="text/javascript">
        $(document).ready(function () {
                    serviceUrl: "api/reports/",
                    reportSource: { report: 1 }                

    where x.x.x.x is the version of the HTML5 ReportViewer/Telerik Reporting (e.g.

  4. To create the database use the following script:

    USE [master]
    ( NAME = N'Reports', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\Reports.mdf' , SIZE = 4096KB ,
    LOG ON
    ( NAME = N'Reports_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\Reports_log.ldf' , SIZE = 1024KB
    , MAXSIZE = 2048GB , FILEGROWTH = 10%)
    USE [Reports]
    CREATE TABLE [dbo].[Reports](
    [ID] [int] NOT NULL,
    [Definition] [nvarchar](max) NOT NULL
  5. To enter some data into the database you can manually edit the Reports table. XML report definitions can be obtained from the sample .trdx report files installed together with the product and are located in [Telerik_Reporting_Install_Dir]\Report Designer\Examples.

    In newer versions, all sample reports of the Standalone Report Designer are in TRDP format. You can use the Standalone Report Designer - File - Save As option to convert them to TRDX files.

In this article
Not finding the help you need?