Access to parameter value change for a hosted viewer control

Posted by: seaninglis on 19 July 2023, 2:51 am EST

    • Post Options:
    • Link

    Posted 19 July 2023, 2:51 am EST

    Hi,

    Currently using 3.2 to host a reportviewer component in an Angular 14 app.

    I need to a way to detect the values a user has selected in the built-in parameters flyout when they are generating report. To be clear, this is not accessing the value of selected parameters within the report itself, but accessing selected values from the host application.

    I’ve had a good look through 3.2 documentation (I think) and I can’t see any documented events that might be emitted when these change.

    Similarly, I haven’t found a way to inspect the properties of any of the obvious objects to get to the selected value; lots of ways to get to the default parameter values as they were passed in to the report, but no way to access any changes the user may have made.

    What am I missing?

    Thanks

    Sean

  • Posted 31 July 2023, 8:29 pm EST

    Hi Sean,

    Unfortunately, there’s no direct way to handle any event to get the change in the parameter value.

    However, you can modify the DOM to access the value of your parameter on change. As you want to get the change in the parameter value from the SideBar, for each parameter value an ‘id’ is generated for its ‘input’ HTML component you can handle its ‘change’ event to call your own javascript method every time the value of your Parameter gets changed.

    Please find attached an angular sample implementing the same.

    Regards,

    Anand

    AngularProject.zip

  • Posted 1 August 2023, 12:45 am EST

    Hi Anand,

    Thanks for the example.

    Unfortunately most of our parameters of interest are boolean toggles or dropdown lists, and these don’t appear to be backed by straightforward input fields with an Id as in the example.

    I can see how in theory I might find these by using the for=“xxxxx” attribute of the related label, then descending through the DOM to see if I can get the pseudo radio button / list and perhaps attach to a click event, but is there a more straightforward way to do it?

    The approach seems very fragile.

    S

  • Posted 2 August 2023, 3:27 pm EST

    Hi Sean,

    The viewer has an event ‘reportLoaded’ which gets called when the report gets loaded after the ‘viewer.Load()’ method but before the parameters are passed into the report. However, this event receives the report JSON as an argument you can store this into a variable and then also handle the ‘documentLoaded’ event of the viewer which gets called when the parameters are passed into the report and the report document is loaded into the viewer.

    In the handler for the ‘documentLoaded’ event, you can use your report variable to get the various parameters and their values every time the report is loaded with a new parameter value.

    Please find attached a simple project implementing the same.

    Regards,

    Anand

    ParameterReport.zip

  • Posted 2 August 2023, 6:19 pm EST

    Hi Anand,

    With a bit of twisting TypeScript’s arm, this gives me exactly what I need, thanks.

    Sean

  • Posted 2 August 2023, 7:44 pm EST

    Hi Sean,

    We’re glad we were able to help!

    Regards,

    Anand

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels