We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

ReportViewer (BoldReportsAPIController) global variable access

Hi

I have a Report.razor page

@code {


     [parameter]

     public string repName { get; set; } = "";


     [injection]

     protected Data.LoginState LoginState { get; set; }

...

public async void RenderReportViewer()

     {

         viewerOptions.ReportName = repName;

         viewerOptions.ServiceURL = "/api/BoldReportsAPI";


         await JSRuntime.InvokeVoidAsync("BoldReports.RenderViewer", "report-viewer", viewerOptions);

     }

-------------------------------------------------- -------------------

And in BoldReportsAPIController

[NonAction]

         public void OnInitReportOptions(ReportViewerOptions reportOption)

         {

                 string basePath = _hostingEnvironment.WebRootPath;

                 reportOption.ReportModel.ProcessingMode = ProcessingMode.Local;

                 FileStream inputStream = new FileStream(basePath + @"\resources\" + reportOption.ReportModel.ReportPath + ".rdlc", System.IO.FileMode.Open, System.IO.FileAccess.Read);

                 MemoryStream reportStream = new MemoryStream();

                 inputStream.CopyTo(reportStream);

                 reportStream.Position = 0;

                 inputStream.Close();

                 reportOption.ReportModel.Stream = reportStream;


This is where I need to create the data for the report

reportOption.ReportModel.DataSources.Add(new BoldReports.Web.ReportDataSource { Name = "DSDzial", Value = Date });

How to read the LoginState value here?

I need user data to read from the database.

(LoginState works as

builder.Services.AddScoped<LoginState>();)


Thanks

Regards

Maciej


1 Reply

AM Arumugasami Murugesan Syncfusion Team February 20, 2023 11:17 AM UTC

Hi Maciej,


Thanks for contacting Bold Reports support.


Using ajaxBeforeLoad event, we can pass the data from razor page to API controller. Please refer to the below documentation for your reference..

https://help.boldreports.com/embedded-reporting/javascript-reporting/report-viewer/handle-post-actions/#pass-custom-data-in-ajax-request  


Regards,

Arumugasami M


Loader.
Live Chat Icon For mobile
Up arrow icon