Report parameters

To set report parameters in the Bold Reports® Angular Report Viewer, pass the default values at run time with the parameters property. You can set the report parameters while creating the Report Viewer control in a script or in the Web API Controller.

This tutorial uses the Sales Order Detail.rdl report. Download the Sales Order Detail report.

How do I set a parameter on the client side?

To set a parameter on the client side of the Angular Report Viewer, pass a JSON array with the parameter details to the parameters property.

  • Set the default value data to the values property and name of the report parameter to the name property.

    The parameter name is case sensitive, and it should be same as available in the report definition.

The following code example illustrates how to set a report parameter in the script.

<bold-reportviewer id="reportViewer_Control" style="width: 100%;height: 950px" [reportServiceUrl] = "serviceUrl" [processingMode] = "Remote" [reportPath] = "reportPath" [parameters] = "parameters">
</bold-reportviewer>
import { Component } from '@angular/core';

@Component({
    selector: 'ej-app',
    templateUrl: 'src/reportviewer/reportviewer.component.html',
    styleUrls: ['src/reportviewer/reportviewer.component.css']
})

export class ReportViewerComponent {
    public serviceUrl: string;
    public reportPath: string;
    public serverUrl: string;
    public parameters: any;

    constructor() {

        this.serviceUrl = 'https://demos.boldreports.com/services/api/ReportViewer';
        this.reportPath = 'Sales Order Detail.rdl';
        this.parameters = [{
            name: 'SalesOrderNumber',
            labels: ['SO50751'],
            values: [SO50751],
            nullable: false
            }];
    }
}
  • Build and run the application.

How do I set parameters in the Web API controller?

To set a parameter default value for the Angular Report Viewer in the Web API controller, use the following code in the OnReportLoaded method.

[NonAction]
public void OnReportLoaded(ReportViewerOptions reportOption)
{
    List<BoldReports.Web.ReportParameter> userParameters = new List<BoldReports.Web.ReportParameter>();
    userParameters.Add(new BoldReports.Web.ReportParameter()
    {
        Name = "SalesOrderNumber",
        Values = new List<string>() { "SO50756" }
    });
    reportOption.ReportModel.Parameters = userParameters;
}

Report parameter names are case sensitive.

How do I get the report parameters?

To get the report parameters used in a report, call the ReportHelper class methods in the Angular Report Viewer Web API controller. The following helper methods get parameters with or without values.

Methods Description
GetParameters Returns the parameters used in the current report without the processed values.
GetParametersWithValues Returns the report parameters with processed data values that are used in the current report.

You can use the following code sample to get parameter names and set parameter default values.

    public class ReportsApiController : ApiController, IReportController
    {
        Dictionary<string, object> jsonArray = null;
        public object PostReportAction(Dictionary<string, object> jsonResult)
        {
            jsonArray = jsonResult;
            return ReportHelper.ProcessReport(jsonResult, this);
        }

        ....
        [NonAction]
        public void OnReportLoaded(ReportViewerOptions reportOption)
        {
            var reportParameters = ReportHelper.GetParameters(jsonArray, this);
            List<BoldReports.Web.ReportParameter> modifiedParameters = new List<BoldReports.Web.ReportParameter>();

            if (reportParameters != null)
            {
                foreach (var rptParameter in reportParameters)
                {
                    modifiedParameters.Add(new BoldReports.Web.ReportParameter()
                    {
                        Name = rptParameter.Name,
                        Values = new List<string>() { "SO50756" }
                    });
                }

                reportOption.ReportModel.Parameters = modifiedParameters;
            }
        }
    }

How do I change the parameter drop-down height and width?

To change the height and width of the parameter drop-down in the Angular Report Viewer parameter panel, use the parameterSettings property.

<bold-reportviewer id="reportViewer_Control" style="width: 100%;height: 950px" [reportServiceUrl] = "serviceUrl"
 [reportPath] = "reportPath" [parameterSettings] = "parameterSettings">
</bold-reportviewer>
export class AppComponent {
  public parameterSettings: any;

    constructor() {
       this.parameterSettings= {
        popupHeight: "200px",
        popupWidth: "150px",
    }
    }
}

How do I hide the parameter scroller?

To hide the scrollbar in the Angular Report Viewer parameter panel, use the enableparameterblockscroller property.

<bold-reportviewer id="reportViewer_Control" style="width: 100%;height: 950px" [reportServiceUrl] = "serviceUrl" [reportPath] = "reportPath" [enableParameterBlockScroller]= false >
</bold-reportviewer>

How do I hide the parameter pane on load?

To hide or show the parameter block in the Angular Report Viewer, use the parameterSettings property.

<bold-reportviewer id="reportViewer_Control" style="width: 100%;height: 950px" [reportServiceUrl] = "serviceUrl"
 [reportPath] = "reportPath" [parameterSettings] = "parameterSettings">
</bold-reportviewer>
export class AppComponent {
  public parameterSettings: any;

    constructor() {
      this.parameterSettings=  { hideParameterBlock: true}
    }
}

How do I change the parameter item width and label width?

To change the parameter item width and label width in the Angular Report Viewer, use the parameterSettings property.

<bold-reportviewer id="reportViewer_Control" style="width: 100%;height: 950px" [reportServiceUrl] = "serviceUrl"
 [reportPath] = "reportPath" [parameterSettings] = "parameterSettings">
</bold-reportviewer>
export class AppComponent {
  public parameterSettings: any;

    constructor() {

       this.parameterSettings={
            itemWidth: '250px',
            labelWidth: 'auto'
        }
    }
}

How do I set a date range for a date parameter?

To set a date range for date parameters in the Angular Report Viewer, use the minDateTime and maxDateTime properties in the parameterSettings.

Property Description
minDateTime Specify minimum range value of a date parameter
maxDateTime Specify maximum range value of a date parameter
<bold-reportviewer id="reportViewer_Control" style="width: 100%;height: 950px" [reportServiceUrl] = "serviceUrl"
 [reportPath] = "reportPath" [parameterSettings] = "parameterSettings">
</bold-reportviewer>
export class AppComponent {
  public serviceUrl: string;
  public reportPath: string;
  public parameterSettings: any;

  constructor() {
    this.serviceUrl = "https://demos.boldreports.com/services/api/ReportViewer";
    this.reportPath = "~/Resources/demos/Report/product-line-sales.rdl";
    this.parameterSettings = {
      minDateTime: new Date("4/5/2003"),
      maxDateTime: new Date("6/15/2003"),
    };
  }
}

The previous code sets the date range for all the date parameters used in the report.

To set a different date range for each date parameter used in the report, register the beforeParameterAdd event and specify the range based on the parameter name, as in the following code sample.

<bold-reportviewer id="reportViewer_Control" style="width: 100%;height: 950px"
    [reportServiceUrl] = "serviceUrl"
    [processingMode] = "Remote"
    [reportServerUrl] = "serverUrl"
    [reportPath] = "reportPath"
    (beforeParameterAdd) = "onBeforeParameterAdd($event)">
</bold-reportviewer>
import { Component, ViewChild } from '@angular/core';
import { BoldReportsAngularModule } from '@boldreports/angular-reporting-components/src/core';

@Component({
  selector: 'ej-app',
  templateUrl:'./app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  public serviceUrl: string;
  public reportPath: string;

  constructor() {
    this.serviceUrl = 'https://demos.boldreports.com/services/api/ReportViewer';
    this.reportPath = 'product-line-sales.rdl';
  }

  onBeforeParameterAdd(event) {
    event.parameterSettings.dateTimePickerType = "DateTime";
    if (event.parameterModel.Name === "StartDate") {
      event.parameterSettings.minDateTime = new Date("4/5/2003 5:00:00 AM");
      event.parameterSettings.maxDateTime = new Date("4/15/2003 5:00:00 AM");
    }
    if (event.parameterModel.Name === "EndDate") {
      event.parameterSettings.minDateTime = new Date("5/10/2003 5:00:00 AM");
      event.parameterSettings.maxDateTime = new Date("5/20/2003 5:00:00 AM");
    }
  }
}

How do I set the date and time display format for a date parameter?

To set the date and time format that the DateTimePicker control displays for date parameters in the Angular Report Viewer, use the dateTimeFormat and timeDisplayFormat properties in the parameterSettings.

Format Display in DateTimePicker
Short Date and Time - d/M/yy h:mm tt 9/12/2014 2:04 PM
Medium Date - d MMM yy h:mm tt 12 Sep 14 2:04: PM
Full Date and short time - dddd, MMMM dd, yyyy HH:mm tt Friday, September 12,2014 2:04 PM
Full Date and Long Time - dddd, MMMM dd, yyyy HH:mm:ss tt Friday, September 12,2014 2:04:00 PM
UTC - yyyy-MM-dThh:mm:ssz 2014-09-12T2:04:00+5
<bold-reportviewer id="reportViewer_Control" [reportServiceUrl] = "serviceUrl"
 [reportPath] = "reportPath" [parameterSettings] = "parameterSettings">
</bold-reportviewer>
export class AppComponent {
  public serviceUrl: string;
  public reportPath: string;
  public parameterSettings: any;

  constructor() {
    this.serviceUrl = 'https://demos.boldreports.com/services/api/ReportViewer';
    this.reportPath = 'product-line-sales.rdl';
    this.parameterSettings = {
      dateTimePickerType: "DateTime",
      dateTimeFormat: "MM/dd/yyyy h:mm tt",
      timeDisplayFormat: "HH:mm",
      timeInterval: 60,
    };
  }
}

The previous code sets the date and time display format for all the date parameters used in the report.

To set a different date and time display format for each date parameter used in the report, register the beforeParameterAdd event and specify the format based on the parameter name, as in the following code sample.

<bold-reportviewer id="reportViewer_Control"
    [reportServiceUrl] = "serviceUrl"
    [processingMode] = "Remote"
    [reportServerUrl] = "serverUrl"
    [reportPath] = "reportPath"
    (beforeParameterAdd) = "onBeforeParameterAdd($event)">
</bold-reportviewer>
import { Component, ViewChild } from "@angular/core";

@Component({
  selector: 'ej-app',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  public serviceUrl: string;
  public reportPath: string;
  public serverUrl: string;

  constructor() {
    this.serviceUrl = 'https://demos.boldreports.com/services/api/ReportViewer';
    this.reportPath = '~/Resources/demos/Report/product-line-sales.rdl';
  }

  onBeforeParameterAdd(event) {
    event.parameterSettings.dateTimePickerType = "DateTime";
    if (event.parameterModel.Name === "StartDate") {
      event.parameterSettings.dateTimeFormat = "MM/dd/yyyy h:mm tt";
      event.parameterSettings.timeDisplayFormat = "HH:mm";
      event.parameterSettings.timeInterval = 60;
    }
    if (event.parameterModel.Name === "EndDate") {
      event.parameterSettings.dateTimeFormat = "MM/dd/yyyy h:mm tt";
      event.parameterSettings.timeDisplayFormat = "HH:mm";
      event.parameterSettings.timeInterval = 60;
    }
  }
}

How do I access hidden or internal parameter information?

To expose the hidden or internal report parameter information used in a report to the user, set the accessInternalValue property in the Angular Report Viewer parameterSettings.

<bold-reportviewer id="reportViewer_Control" [reportServiceUrl] = "serviceUrl"
 [reportPath] = "reportPath" [parameterSettings] = "parameterSettings">
</bold-reportviewer>
export class AppComponent {
  public parameterSettings: any;

    constructor() {
      this.parameterSettings=  { accessInternalValue: true}
    }
}

How do I set report parameter visibility in the Web API controller?

To show or hide a parameter at the top of the Angular Report Viewer panel, set the Hidden property of ReportParameter in the Web API controller. The following code example shows hiding a report parameter in the Web API controller’s OnReportLoaded method.

    [NonAction]
    public void OnReportLoaded(ReportViewerOptions reportOption)
    {
        var reportParameters = ReportHelper.GetParameters(jsonArray, this);
        List<BoldReports.Web.ReportParameter> modifiedParameters = new List<BoldReports.Web.ReportParameter>();

        if (reportParameters != null)
        {
            foreach (var rptParameter in reportParameters)
            {
                modifiedParameters.Add(new BoldReports.Web.ReportParameter()
                {
                    Name = rptParameter.Name,
                    Hidden = true
                });
            }

            reportOption.ReportModel.Parameters = modifiedParameters;
        }
    }