This is a migrated thread and some comments may be shown as answers.

limiting Export options in an ASP.NET Core project

2 Answers 243 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Doug
Top achievements
Rank 1
Doug asked on 14 Jul 2017, 04:37 PM

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 Answers, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 18 Jul 2017, 01:24 PM
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
0
Ikhwan
Top achievements
Rank 1
answered on 22 Dec 2019, 01:20 AM
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...
    //
}
Tags
General Discussions
Asked by
Doug
Top achievements
Rank 1
Answers by
Stef
Telerik team
Ikhwan
Top achievements
Rank 1
Share this question
or