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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Report Parameters not filtering data

Thread ID:

Created:

Updated:

Platform:

Replies:

148108 Oct 6,2019 12:41 PM UTC Oct 9,2019 06:39 AM UTC Report Platform 6
loading
Tags: Report Viewer
James Bridgeford
Asked On October 6, 2019 12:41 PM UTC

I've added a single parameter to my report that gets it's values from the query.  That works just fine and I can see the values selectable.  The problem comes in that it doesn't filter the data set when I make a selection and hit view report.  I looked through the documentation and everything dealing with Parameters is about setting a default.  Is there something I'm supposed to be capturing to handle report filtering based on parameters?

James Bridgeford
Replied On October 6, 2019 09:37 PM UTC

After a bit more work, I'm at a complete loss. 
1. I must select an option for the param and hit view report even though I set a default on the param.
       a. Expected Behavior is that on first run it will take the default value set on the param and run the report without having to hit View Report
2. When Selecting an option and clicking view report, it does not filter the data
      a. Expected Behavior is that when selecting values for each parameter and hitting View Report that the report data is narrowed to only the values that match the params.
3. When handling params in the PostReportAction method I'm not able to effect the Data being shown even if I set the data source on the jsonResult.
       a. Expected Behavior is when handling the params for filtering data on the Server Side that the new Datasource is used instead of the existing one.

Here is the code behind the PostReportAction:

[HttpPost, Route("PostReportAction")]
        public object PostReportAction(Dictionary<string, object> jsonResult)
        {
            if (jsonResult.TryGetValue("parameters", out var parameters)
                   && parameters != null && !string.IsNullOrWhiteSpace(parameters.ToString()))
            {
                var parms = JsonConvert.DeserializeObject<List<ReportParameters>>(parameters.ToString());
                var woItem = parms.FirstOrDefault(i => i.name == "WOItem");
                if (woItem != null)
                {
                    var value = woItem.values.FirstOrDefault();
                    if (!string.IsNullOrWhiteSpace(value))
                    {
                        var reportData = GetCombinedFinancialData(value);
                        jsonResult["dataSources"] = JsonConvert.SerializeObject(new Syncfusion.Reporting.Web.ReportDataSource() { Name = "MSRFSR", Value = reportData });
                        jsonResult["dataRefresh"] = true;
                    }
                }
            }

            return ReportHelper.ProcessReport(jsonResult, this);
        }

Mahendran Shanmugam [Syncfusion]
Replied On October 7, 2019 07:32 AM UTC

Hi James, 

Could you please confirm whether you are using RDL or RDLC report at your end, because your first query explains you are using the RDL and second one explains RDLC report. If you are using the RDL report then it will filtering the data based on RDL Dataset query. But if you are using RDLC then we need to filtering the data as user defined. 

Regards, 
Mahendran S. 


James Bridgeford
Replied On October 7, 2019 11:12 AM UTC

I am using rdlc reports.

Mahendran Shanmugam [Syncfusion]
Replied On October 8, 2019 01:41 PM UTC

Hi James, 

We were able to reproduce the data not loading issue when we passing the data from PostReportAction method. So could you please pass the filtered data in OnReportLoaded method to avoiding the mentioned problem at your end as shown in below code example. 
App.component.ts: 
export class AppComponent { 
  title = 'reportviewerapp'; 
  public serviceUrl: string; 
  public reportPath: string; 
  public parameters: any; 
 
    constructor() { 
      this.serviceUrl = 'http://localhost:53800/api/Home';  
      this.reportPath = '/ReportData/Region.rdlc'; 
      this.parameters = [{ 
        name: 'CustomerID',  
        labels: ['InvoiceID'],  
        values: [10250],  
        nullable: false  
        }]; 
    } 
} 
 

Homecontroller.cs: 
public partial class HomeController : Controller, IReportController 
    { 
        private IMemoryCache _cache; 
        private IHostingEnvironment _hostingEnvironment; 
        private Dictionary<string, object> jsonArray; 
 
        public HomeController(IMemoryCache memoryCache, IHostingEnvironment hostingEnvironment) 
        { 
            _cache = memoryCache; 
            _hostingEnvironment = hostingEnvironment; 
        } 
 
        [HttpPost] 
        public object PostReportAction([FromBody] Dictionary<string, object> jsonResult) 
        { 
            jsonArray = jsonResult; 
            return ReportHelper.ProcessReport(jsonResult, this, this._cache); 
        } 
 
        [ActionName("GetResource")] 
        [AcceptVerbs("GET")] 
        public object GetResource(ReportResource resource) 
        { 
            return ReportHelper.GetResource(resource, this, _cache); 
        } 
 
        [HttpPost] 
        public object PostFormReportAction() 
        { 
            return ReportHelper.ProcessReport(null, this, this._cache); 
        } 
 
        public void OnInitReportOptions(ReportViewerOptions reportOption) 
        { 
            string basePath = _hostingEnvironment.WebRootPath; 
            FileStream inputStream = new FileStream(basePath + reportOption.ReportModel.ReportPath, FileMode.Open, FileAccess.Read); 
            reportOption.ReportModel.Stream = inputStream; 
            reportOption.ReportModel.ProcessingMode = ProcessingMode.Local; 
        } 
 
        public void OnReportLoaded(ReportViewerOptions reportOption) 
        { 
            var parameters = ReportHelper.GetParameters(jsonArray, this, _cache); 
 
            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])) }); 
            } 
        } 
    } 

We have prepared the simple sample for your reference and it can be downloaded from below location. 

Regards, 
Mahendran S. 


James Bridgeford
Replied On October 8, 2019 11:31 PM UTC

So, this is my fault for not specifying, but I am using the MVC control and full .net framework.  I'm assuming the example holds mostly true for that as well, but are there any differences I should be aware of?  Also what are you using as your caching source?  Also, OnReportLoaded doesn't fire when clicking on View Report after hitting the filters. 

Vinoth Srinivasan [Syncfusion]
Replied On October 9, 2019 06:39 AM UTC

Hi James, 
 
Sorry for the inconvenience caused. 
 
We are getting issue when passing the list values directly for the ReportDatasource. So, could you please pass the ReportDatasource value using the new class file as shown in below code example to avoid the mentioned problem at your end. 
 
public object PostReportAction(Dictionary<string, object> jsonResult) 
{ 
    if (jsonResult.TryGetValue("parameters", out var parameters) 
            && parameters != null && !string.IsNullOrWhiteSpace(parameters.ToString())) 
    { 
        var parms = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Syncfusion.Reporting.Web.ReportParameter>>(parameters.ToString()); 
        var param = parms.FirstOrDefault(i => i.Name == "ReportParameter1"); 
        if (param != null) 
        { 
            var value = param.Values.FirstOrDefault(); 
            if (!string.IsNullOrWhiteSpace(value)) 
            { 
                var reportData = ProductList.GetData(value); 
                List<ReportDataSourceExt> extensionDataSources = new List<ReportDataSourceExt>() { new ReportDataSourceExt() { name = "list", value = reportData } }; 
                jsonResult["dataSources"] = Newtonsoft.Json.JsonConvert.SerializeObject(extensionDataSources); 
                jsonResult["dataRefresh"] = true; 
            } 
        } 
    } 
    return ReportHelper.ProcessReport(jsonResult, this); 
} 
 
public class ReportDataSourceExt 
{ 
    public string name { get; set; } 
    public object value { get; set; } 
} 
 
 
Regards, 
Vinoth S. 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon