Starting in 2019, the Reporting control is no longer included in Essential Studio®. If you're experiencing issues with the Syncfusion� Reporting Platform, Report Viewer, Report Designer, or Report Writer, we recommend migrating to Bold Reports, our dedicated reporting platform.

Bold Reports offers a comprehensive suite of tools and features for all your reporting needs, and we will help you make a smooth transition from the discontinued control. Our support team at https://support.boldreports.com/ is here to assist you with any questions or difficulties you may encounter during the migration process.

We thank you for choosing Syncfusion� and appreciate your understanding.

Report Viewer (Bold report viewer) - RDLC parameters

Hi,

I'm using ASP .NET Core package (https://www.syncfusion.com/aspnet-core-ui-controls).
Bold Report Viewer is part of this package.

I have ReportViewer (bold-report-viewer) control in my view (cshtml) and a controller that implementsIReportController interface.
I'm using RDLC (local) template and BoldReports.Web.ReportDataSource is being set to ReportModel DataSources using custom logic - i.e. a DB call to some SP.
This is done in OnInitReportOptions method.

Let's say that Rdlc has one parameter - @Param1;


Parameter is displayed correctly in preview header part. After filling parameter value, and pressing View report button, parameter is displayed on generated report field.



My problem here is that I would like to use this parameter to call SP again using provided parameter.
When View Report button is clicked, PostReportAction is being called and parameters are there, in json array.



I've tried to set these properties
jsonArray["refresh"] = true
jsonArray["reportRefresh"] = true
in order to trigger report loading or something else so that i can fill data source again by calling SP with provided parameter.

How can I do this?


Thanks!

7 Replies

MS Muthuramana Sankaranarayanan Syncfusion Team March 9, 2020 02:26 PM UTC

Hi Danilo,  
Thanks for your interest in Bold Reports. 
We cannot able to change the RDLC datasource when changing the parameter values in parameter dialog. But we can able to filter the data for RDLC report at programmatically as shown in below code when clicking the external button in example.  
@using BoldReports.Web; 
<div style="height:800px"> 
    <label> 
        CustomerID: 
        <input type="text" name="CustomerID" id="customerid"> 
    </label> 
    <input type="button" value="Submit" onclick=onClick()> 
    <bold-report-viewer id="viewer" 
                        report-path="Region.rdlc" 
                        report-service-url="/api/ReportViewer" 
                        processing-mode="Local" 
                        ajax-before-load="ajaxBeforeLoad"> 
    </bold-report-viewer> 
</div> 
<script type="text/javascript"> 
    var parameters = [{ 
        name: 'CustomerID', 
        labels: ['29661'], 
        values: [29661], 
        nullable: false 
    }]; 
    function ajaxBeforeLoad(event) { 
        event.data = parameters; 
    }; 
    function onClick(element) { 
        parameters = [{ 
            name: 'CustomerID', 
            labels: [document.getElementById("customerid").value], 
            values: [document.getElementById("customerid").value], 
            nullable: false 
        }]; 
        var reportviewer = $("#viewer").data('boldReportViewer'); 
        reportviewer.setModel({ "parameters": parameters }); 
    }; 
</script> 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
Also use the below code snippet in the report controller for the datasource to change when changing the parameter 
public void OnInitReportOptions(ReportViewerOptions reportOption) 
        { 
            List<BoldReports.Web.ReportParameter> userParameters = new List<BoldReports.Web.ReportParameter>(); 
            userParameters.Add(new BoldReports.Web.ReportParameter() 
            { 
                Name = "CustomerID", 
                Values = new List<string>() { "29661" } 
            }); 
            string basePath = _hostingEnvironment.WebRootPath; 
            reportOption.ReportModel.ProcessingMode = ProcessingMode.Local; 
            FileStream inputStream = new FileStream(basePath + @"\Resources\Region.rdlc", FileMode.Open, FileAccess.Read); 
            reportOption.ReportModel.Stream = inputStream; 
            var parameters = new List<ReportParameter>(); 
            if (DefaultParam != null) 
            { 
                parameters = JsonConvert.DeserializeObject<List<ReportParameter>>(DefaultParam); 
            } 
            if (parameters != null && parameters.Count > 0) 
            { 
                reportOption.ReportModel.DataSources.Clear(); 
                reportOption.ReportModel.DataSources.Add(new ReportDataSource { Name = "StoreSales", Value = StoreSales.GetData(Convert.ToInt32(parameters[0].Values[0])) }); 
            } 
        } 
 
 
Please find the below attached sample for your reference. 
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/ASP.NET_Core_Viewer1719560546.zip 
Regards, 
Muthu Ramana S 




DA Danilo A March 10, 2020 12:57 PM UTC

Hi,

Just to be precise... 

So, it's not possible to trigger reloading from PostReportAction in any way?

Regards


MS Muthuramana Sankaranarayanan Syncfusion Team March 11, 2020 07:13 AM UTC

Hi Danilo, 
 
It is not possible to reload on PostReportAction since we will be calling the method only one time, that is on loading the report viewer. So, could you please set the filter for report items based on parameters as shown in below example. 
 

Regards, 
Muthu Ramana S 



DA Danilo A March 12, 2020 06:49 PM UTC

Hi,

Thanks!

Is there a way that i can pass withCredentials = true property with Ajax request?

Something similar like I did by overriding ajaxRequestSettings on ejs-pdfviewer?

i.e.
    var ajaxSettings = new Syncfusion.EJ2.PdfViewer.PdfViewerAjaxRequestSettings();
    ajaxSettings.WithCredentials = true;
    ajaxSettings.AjaxHeaders = headers;
}
<div class="control-section">
    <ejs-pdfviewer id="pdfviewerComponent"
                   serviceUrl="@url"
                   documentPath="@path"
                   enableMagnification="true"
                   ajaxRequestSettings=@ajaxSettings>
    </ejs-pdfviewer>
</div>

Thanks


MS Muthuramana Sankaranarayanan Syncfusion Team March 13, 2020 11:02 AM UTC

Hi Danilo, 

Thanks for your patience. 

We cannot can pass “withCredentials = true” property with Ajax request. Instead you can use the “ajaxsetup”  in the script like following code snippet to resolve this, 
 
$.ajaxSetup({ 
    type: "POST", 
    xhrFields: { 
       withCredentials: true 
    }, 
    crossDomain: true 
}); 
 
 
Also if you need to pass headers we can do it using the Ajax request as like in the following documentation link, 
 

Regards, 
Muthu Ramana S 



DA Danilo A March 13, 2020 11:33 AM UTC

Hi Matu,

Thank you! This is exactly what i need.

You can close this ticket.

Regards,
Danilo


MS Muthuramana Sankaranarayanan Syncfusion Team March 13, 2020 11:41 AM UTC

Hi Danilo, 
  
Thanks for the update. 
  
Regards, 
Muthu Ramana S 


Loader.
Up arrow icon