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
If you became a customer of the Syncfusion Reporting Platform or the Report Viewer, Report Designer, or Report Writer components before October 2019 and have questions related to those products, you can request support through our forum system. However, please note that this support system is only for existing customers who are still using the Syncfusion Reporting Platform or its components and not for new customers looking for reporting products from Syncfusion.

For new customers or those with general reporting questions, we recommend contacting our support team at https://support.boldreports.com/, which is a separate brand created by Syncfusion for its reporting solutions. Our team will be happy to assist you with any questions you may have.

Thank you for choosing Syncfusion for your reporting needs.

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