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.

Report Parameters not filtering data

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?

6 Replies

JB James Bridgeford 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);
        }


MS Mahendran Shanmugam Syncfusion Team 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. 



JB James Bridgeford October 7, 2019 11:12 AM UTC

I am using rdlc reports.


MS Mahendran Shanmugam Syncfusion Team 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. 



JB James Bridgeford replied to Mahendran Shanmugam 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. 


VS Vinoth Srinivasan Syncfusion Team 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. 


Loader.
Live Chat Icon For mobile
Up arrow icon