Skip to main content
All docs
V25.2
  • DxReportViewer.ParametersModel Property

    Provides access to report parameters.

    Namespace: DevExpress.Blazor.Reporting

    Assembly: DevExpress.Blazor.Reporting.v25.2.Viewer.dll

    NuGet Package: DevExpress.Blazor.Reporting.Viewer

    Declaration

    public ParametersModel ParametersModel { get; }

    Property Value

    Type Description
    ParametersModel

    An object that contains report parameters and allows you to manage them.

    Remarks

    The ParametersModel property returns a ParametersModel object that allows you to get visible parameters, and reset or submit parameters in code. The reset or submit operation is equivalent to the user clicking the Reset or Submit button in the Parameters panel.

    The following code snippet handles the OnCustomizeParameters event and obtains a ParameterModel for the OrderIdParameter parameter:

    void OnCustomizeParameters(ParametersModel parameters)
    {
        ParameterModel = parameters.VisibleItems
            .Where(param => param.Name == "OrderIdParameter")
            .FirstOrDefault();
    }
    

    Example

    Important

    Customization options described in this example are available to owners of DevExpress ASP.NET & Blazor Subscription, DXperience, or Universal subscription (subscriptions that include DevExpress ASP.NET & Blazor UI Controls). The DevExpress Reporting Subscription does not support UI customization in Report Viewer or End-User Report Designer.

    Refer to the following help topic for information on subscription options: Installation - Subscriptions that Include Reporting Components.

    You can hide the Parameter Panel and define a custom editor to specify parameter values:

    Blazor Report Viewer - Standalobe Parameter Editor

    The code below does the following:

    • Hides the Parameter Panel through the Viewer’s TabPanelModel property.
    • Creates a custom component based on DxComboBox to allow users to specify the report parameter value. The OnCustomizeParameters is handled to specify the created editor as the editor for the OrderIdParameter parameter.
    • Creates a DxButton that handles user clicks and passes the specified parameter value to the Report Viewer. The OnSubmitParameters() method is triggered to build the report document with a new parameter value.
    @page "/standalonepanel/"
    
    @using DevExpress.Blazor.Reporting
    @using DevExpress.XtraReports.UI
    @using BlazorCustomization.PredefinedReports
    @using DevExpress.Blazor.Reporting.Models
    @using DevExpress.Blazor
    @using Models
    
    <div class="cw-880">
        <EditForm Model="@OrdersModel"
                  OnValidSubmit="@HandleValidSubmit"
                  Context="EditFormContext">
            <DataAnnotationsValidator />
            <DxFormLayout CssClass="w-75 parameters-panel-custom">
                <DxFormLayoutItem Caption="Order Id:" ColSpanMd="4">
                    <CustomCombobox Model=OrdersModel ParameterModel=ParameterModel />
                </DxFormLayoutItem>
                <DxFormLayoutItem ColSpanMd="1">
                    <DxButton SubmitFormOnClick="true"
                              Text="Submit"
                              Title="Press the key to reload the report with the parameters."
                              RenderStyle="ButtonRenderStyle.Secondary" />
                </DxFormLayoutItem>
                <DxFormLayoutItem ColSpanMd="7">
                    <ValidationSummary />
                </DxFormLayoutItem>
            </DxFormLayout>
        </EditForm>
    </div>
    
    <div style="width: 100%; height: calc(100% - 4rem);">
        <DxReportViewer @ref="reportViewer"
                        OnCustomizeParameters="OnCustomizeParameters"
                        Report="Report" />
    </div>
    
    @code {
        DxReportViewer reportViewer;
        XtraReport Report = new TableReport();
        OrdersModel OrdersModel = new OrdersModel();
        ParameterModel ParameterModel { get; set; }
    
        protected override void OnAfterRender(bool firstRender)
        {
            if (firstRender)
            {
                var parameterTab = reportViewer.TabPanelModel.Tabs
                    .Where(Tab => Tab.ContentModel is ParametersModel)
                    .FirstOrDefault();
                parameterTab.Visible = false;
                StateHasChanged();
            }
            base.OnAfterRender(firstRender);
        }
    
        void HandleValidSubmit()
        {
            if (!OrdersModel.OrdersData.Contains(OrdersModel.OrderId))
            {
                OrdersModel.OrdersData.Add(OrdersModel.OrderId);
                OrdersModel.OrdersData.Sort();
            }
            reportViewer.ParametersModel.OnSubmitParameters();
        }
    
        void OnCustomizeParameters(ParametersModel parameters)
        {
            ParameterModel = parameters.VisibleItems
                .Where(param => param.Name == "OrderIdParameter")
                .FirstOrDefault();
        }
    }
    
    See Also