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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

how to use parameter on reportviewer ASP.NET MVC 5

Thread ID:

Created:

Updated:

Platform:

Replies:

124697 Jun 23,2016 07:54 AM UTC Jun 29,2016 06:45 AM UTC ASP.NET MVC 7
loading
Tags: ReportViewer
demis
Asked On June 23, 2016 07:54 AM UTC

Dears,
Greeting!
I have been working on Syncfusion Essential Studio Report Designer, I can be able to design .rdl reports and integrate with my MVC 5 application. but I am facing some difficulties, while using parameters. I have added the parameter I want on my report, the parameter is displayed on the report, but it is not working. would you please assist me on this
here is the screenshot of the report

Regards,

demis
Replied On June 23, 2016 08:05 AM UTC

sorry for the inconvenience. here is the link to the screenshot of the report

https://drive.google.com/file/d/0BzNtrMxL5QkteXE1c0tlaEhCdW8/view?pref=2&pli=1

Yuvaraj Devarajan [Syncfusion]
Replied On June 24, 2016 05:54 AM UTC

Hi Demis, 
 
Thanks for contacting Syncfusion support. 
 
The mentioned issue might have occurred due to some external CSS style overridden on the parameter block style of your application. We have prepared a sample with query parameter and it can be downloaded from the below location,   
 
 
 
Please refer to the below UG documentation link to create sample in ASP.MVC, 

You can obtain the ASP.Net MVC ReportViewer samples from the below build installed location,   
%userprofile%\AppData\Local\Syncfusion\EssentialStudio\version\MVC\reportsamples   
 
Please share the below details to replicate the mentioned issue.   
1)      Share the referred CSS’s to check the parameter block style issue.   
2)      Provide us the used query parameter and parameter details.   
3)      Confirm your product version.   
 
Regards, 
Yuvaraj D. 


demis
Replied On June 24, 2016 10:50 AM UTC

Dear Yuvaraj D.

Thank you for your info!

I have seen all the resources that you have shared. what i faced is when i click View Report button, the result displaying is not actually based on the filter  parameter data, it displays all the data,



Regards,

demis
Replied On June 24, 2016 11:03 AM UTC

Here is additional information,

Here is the query from report designer side. 

<Query>
<ElementPath>Root /S {@FullName,  @StartDate ,@ActionType,@EndDate,@ActionReason}}
</ElementPath>
<XmlData>
<Root>
<S FullName="Abebe"  StartDate="01-01-2016" ActionType="Hiring" EndDate="1" ActionReason="Vacant"/>

</Root>
</XmlData>
</Query>



Here is the code from the view side

@Html.AntiForgeryToken()
    @(Html.EJ().ReportViewer("reportviewer").ProcessingMode(Syncfusion.JavaScript.ReportViewerEnums.ProcessingMode.Local).ReportPath("~/App_Data/HumanResource/EmpAction.rdl").ReportServiceUrl("/api/ReportAPI").DataSources(t => t.Name("DataSet1").Value(ViewData["DataSet1"]).Add()))

Here is the data from controller action

   ViewData["DataSet1"] = employeeRep.GetEmpActionRep();
            return View();


I have also attached the rdl file

Thank You!

Attachment: EmpAction_8932323d.zip

Yuvaraj Devarajan [Syncfusion]
Replied On June 27, 2016 08:50 AM UTC

Hi Demis, 

We can achieve your requirement to override the View Report Click and doAjaxPost method in your CSHTML page to filter values based on parameter as shown in below code example. 

JS: 
ej.ReportViewer.prototype._viewReportParamsClick = function (event) { 
           var proxy = $('#reportsample').data('ejReportViewer'); 
           var parameters = event.data.params; 
           var reportParams = proxy._getParameterJson(parameters); 
           proxy._refresh = true; 
           $('#' + proxy._id + '_viewBlockContainer .e-reportviewer-viewerblockcontent table:first').attr('isviewclick', 'true'); 
           _params = reportParams;          
           proxy._refreshReport(); 
       } 

WebAPI: 
public void OnReportLoaded(ReportViewerOptions reportOption) 
        { 
            var parameters = new List<Syncfusion.Reports.EJ.ReportParameter>(); 
            if (System.Web.HttpContext.Current.Items.Contains("parakey")) 
            { 
                parameters = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize<List<Syncfusion.Reports.EJ.ReportParameter>>(System.Web.HttpContext.Current.Items["parakey"].ToString()); 
                System.Web.HttpContext.Current.Items.Remove("parakey"); 
            } 
 
            reportOption.ReportModel.Parameters = parameters; 
            if (parameters != null && parameters.Count > 0) 
            { 
                reportOption.ReportModel.DataSources.Clear(); 
                reportOption.ReportModel.DataSources.Add(new ReportDataSource { Name = "StoreSales", Value = StoreSales.GetData(parameters[0].Values[0]) }); 
            } 
            else 
            { 
                reportOption.ReportModel.DataSources.Clear(); 
                reportOption.ReportModel.DataSources.Add(new ReportDataSource { Name = "StoreSales", Value = StoreSales.GetData("GA") }); 
            } 
        } 

We have prepared the sample and it can be downloaded from below location, 

Regards, 
Yuvaraj D. 


demis
Replied On June 28, 2016 07:22 AM UTC

Dear Yuvaraj D. 

Greeting!

Thank you for your quick replay, i think it will help me, but i am unable to download the file, 


Regards,

Yuvaraj Devarajan [Syncfusion]
Replied On June 29, 2016 06:45 AM UTC

Hi Demis, 

We are able to download the previously shared download link and the mentioned problem might have occurred due to slow network connection. So, please check your network connection. For your convenience, we have again uploaded the sample and it can be downloaded from the below location,   

Regards, 
Yuvaraj D. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;