limiting Export options in an ASP.NET Core project

3 posts, 0 answers
  1. Doug
    Doug avatar
    6 posts
    Member since:
    Jun 2017

    Posted 14 Jul 2017 Link to this post

    The most recent Telerik documentation re limiting Export options (http://www.telerik.com/support/kb/reporting/details/limit-export-options-in-reportviewer-to-certain-format-only) recommends adding to the web.config files.  I am working on an ASP.NET Core (VS 2015) project (framework 461).  To my understanding, in an APS.NET Core project, web.config is there just so that the project can be hosted in IIS efficiently.  Configuration is done in appsettings.json  (or config.json). 

    Please describe how to similarly limit Export options in an ASP.NET Core project.

    Thanks.

  2. Stef
    Admin
    Stef avatar
    3610 posts

    Posted 18 Jul 2017 Link to this post

    Hello Doug,

    If you need to limit export options per report, our recommendation is to use CSS to hide the default export option and to add custom UI that uses the HTML5 viewer's exposed API - data attributes and commands. This will let you load only the export options you want and to trigger export through the viewer.

    If you need to limit export options in general for all reports going through the ReportsController in the application, you can add an App.config file on the root level (this is a hack) and add the configuration in it - Connection Strings and Engine Configuration.

    The attached demo project illustrates the settings.


    On a side note, you can host the Reporting REST Service in a separate project with enabled CORS, targeting .NET 461 framework. The viewer in the .NET Core project does not require any Nuget packages, it requests its resources from the Reporting REST Service. Thus you will be able to target more platforms with the client project (the .NET Core project).


    I hope this helps.

    Regards,
    Stef
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Ikhwan
    Ikhwan avatar
    6 posts
    Member since:
    Feb 2011

    Posted 21 Dec 2019 Link to this post

    Sorry for replying to an old thread. I found the easiest way is to just override the GetDocumentFormats method in the reports controller.
        
    [Route("api/reports")]   
    public class ReportsController : ReportsControllerBase
    {
        [HttpGet("formats")]
        public override JsonResult GetDocumentFormats()
        {
            return new JsonResult(new[]
            {
                new {
                    name = "PDF",
                    localizedName = "Acrobat (PDF) file"
                },
                new {
                    name = "XLSX",
                    localizedName = "Excel Worksheet"
                }
            });
        }
     
        //
        // Other setups...
        //
    }
Back to Top