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.

How to create a report with parameters?

Thread ID:

Created:

Updated:

Platform:

Replies:

126152 Sep 27,2016 12:18 PM Sep 30,2016 08:51 AM ASP.NET MVC 5
loading
Tags: ReportViewer
Norberto
Asked On September 27, 2016 12:18 PM

He was looking at the documentation, but as I see this being done in the .rdlc file (in the driver there is nothing, and the same view).

I added the parameters as shown in the following images.






This gives me the following error




My controller
public class ReportController : Controller
    {
        private InterventoriasEntities db = new InterventoriasEntities();

        // GET: Report
        public ActionResult MemoriasDeCalculo()
        {
           
                var proyec = (Entities.Proyecto)Session["proyecto"];
                ViewData["MemoriasCalculos"] = db.sp_memoriasDeCalculoCantidades(proyec.idProyecto).ToList();
                ViewData["InfoProyecto"] = db.sp_infoProyecto(proyec.idProyecto).ToList();
                return View();
           
          
        }
    }


My view
....

                                @(Html.EJ().ReportViewer("reportviewer")
.ProcessingMode(Syncfusion.JavaScript.ReportViewerEnums.ProcessingMode.Local).ReportPath("~/Reports/MemoriasDeCalculoCantidades.rdlc")
.ReportServiceUrl(VirtualPathUtility.ToAbsolute("~/api/ReportApi")).ReportLoaded("onReportLoaded").DataSources(ds => { ds.Name("DataSetMemoriasCalculos").Value(ViewData["MemoriasCalculos"]).Add(); ds.Name("DataSetInfoProyecto").Value(ViewData["InfoProyecto"]).Add(); }))

.....

Is there any example where this report rdlc to guide me? or a solution?

Yuvaraj Devarajan [Syncfusion]
Replied On September 28, 2016 07:40 AM

Hi Norberto, 
 
Thanks for contacting Syncfusion support. 
 
We were unable to reproduce the mentioned issue at our end. The mentioned issue might occur if the given dataset field name in the report parameter available value is not present in the datasource. So please ensure whether the given dataset field is present in datasource. We have prepared the sample with RDLC Report Parameter and it can be downloaded from,   
 
If the issue still persists, then share the issue reproducible RDLC file with local data to validate the mentioned issue at our end.   
 
Regards, 
Yuvaraj D. 


Norberto
Replied On September 28, 2016 10:25 AM

Hello Yuvaraj D.
Thanks for answering.

He was looking at the example, and as I see your .rdlc file, you have a query parameter where there also and I imagine there get data for the report.
<DataSets>
    <DataSet Name="StoreSales">
      <Query>
        <DataSourceName>AdventureWorks2008R2</DataSourceName>
        <QueryParameters>
          <QueryParameter Name="@StateProvinceCode">
            <Value>=Parameters!StateProvinceCode.Value</Value>
          </QueryParameter>
        </QueryParameters>
        <CommandText>SELECT soh.SalesOrderID, soh.TotalDue, soh.OrderDate, c.CustomerID,
   st.Name AS Store,
..................


In my case, I get the data from a stored procedure, I have it in a dataset.
<DataSets>
    <DataSet Name="DataSetMemoriasCalculos">
      <Query>
        <DataSourceName>InterventoriasDataSet</DataSourceName>
        <CommandText>/* Local Query */</CommandText>
      </Query>


I thought I could do a global query, and from this, make a filter with parameters

Yuvaraj Devarajan [Syncfusion]
Replied On September 29, 2016 08:58 AM

Hi Norberto, 

In RDLC Report, we cannot use query parameter to filter the data values from datasource. But we can filter the data from datasource using parameter in dataregion. We have shared the converted RDL file into RDLC report in previous update. Hence the Query parameter are present in RDLC and we won’t process the query parameter for filtering the datasource value.  

In RDL report, we can use query parameter to filter the value from datasource. We have modified the shared sample using RDL query parameter and it can be downloaded from,  

If we have misunderstood your requirement, then share much more information about your scenario to validate the issue. 

Regards, 
Yuvaraj D. 


Norberto
Replied On September 29, 2016 11:43 AM

Hello Yuvaraj D.
First, sorry for not express myself well, I'm using google translator. LOL
I try to explain very well.

For the generation of my reports, I am using a DataSet, where TablaAdapter added through stored procedures. Then I believe my report and select the DataSet and TableAdapter that previously believed.

And the report is displayed correctly.

Now, I want you to report that displays, adding a "filter". The TableAdapter brings me NEXT information.


For example, I want the report has a filter by "idSubCapitulo". Where out a list of data that has that field my TableAdapter and can select the item and view the report.

Enclosed is my report RLCD

Thank you very much.

Attachment: MemoriasDeCalculoCantidades_dadfc3d7.zip

Yuvaraj Devarajan [Syncfusion]
Replied On September 30, 2016 08:51 AM

Hi Norberto, 

We can set/pass the parameter value from viewer to WebAPI in order to filter the data from datasource for RDLC Report using doAjaxPost method in control render viewer page as shown in following shared code example, 
<script type="text/javascript"> 
    var _params = null; 
    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(); 
    } 
 
    ej.ReportViewer.prototype.doAjaxPost = function (type, url, jsondata, onSuccess) { 
        var proxy = $('#reportsample').data('ejReportViewer'); 
        var inVokemethod = onSuccess; 
 
        $.ajax({ 
            type: type, 
            url: url, 
            crossDomain: true, 
            contentType: 'application/json; charset=utf-8', 
            dataType: 'json', 
            data: jsondata, 
            beforeSend: function (req) { 
                if (inVokemethod == "_getDataSourceCredential") { 
                    var _json = jQuery.parseJSON(this.data); 
                    if (_params != null) { 
                        _json["params"] = _params; 
                    } 
                    this.data = JSON.stringify(_json); 
                } 
 
                if (inVokemethod == "_getPageModel" || inVokemethod == "_getPreviewModel") { 
                    if (!proxy._isToolbarClick) { 
                        proxy._showloadingIndicator(true); 
                        proxy._updateDatasource = true; 
                    } else { 
                        proxy._showNavigationIndicator(true); 
                    } 
                } 
                req.setRequestHeader('ejAuthenticationToken', proxy._authenticationToken); 
            }, 
            success: function (data) { 
                if (data && typeof (data.Data) != "undefined") { 
                    data = data.Data; 
                } 
                if (typeof (data) == "string") { 
                    if (data.indexOf("Sf_Exception") != -1) { 
                        proxy._renderExcpetion(inVokemethod + ":" + data); 
                        return; 
                    } 
                } 
                proxy[inVokemethod](data); 
            }, 
        }); 
    } 
 
</script> 

We have prepared the sample with Report Parameter used in RDLC Report and it can be downloaded from, 

So please confirm whether the above solution is same as reported scenario. If the scenario is different than share much more information to provide solution for your requirement at earliest.  

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.

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.

;