This is a migrated thread and some comments may be shown as answers.

Angular Report Viewer Report Source Update

6 Answers 166 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 1
Bob asked on 18 May 2017, 11:31 PM

I'm using the new Angular Report Viewer. My Component allows the user to change different parameters to generate the report. The first time the report runs, everything is fine. When a new set of parameters are selected, requesting the report still shows the report with the initial parameters.

In the prior version, I was able to get this to work by doing this in my ts file:

const v1 = $('#reportViewer1').data('telerik_ReportViewer');
v1.reportSource(requestedReportSource)
v1.refreshReport();

Where requestedReportSource contained the new report parameters.

In the new TelerikReportViewerComponent, I see there' a setReportSource() method, but I'm unable to get the right JSON parameter format to be passed to the method.

Any examples on how to update the ReportSource for the component would be appreciated.

Bob

 

 

6 Answers, 1 is accepted

Sort by
0
Katia
Telerik team
answered on 22 May 2017, 12:56 PM
Hi Bob,

You can check the update in the support ticket #1110176 that you opened on the same question. For other members interested in this topic, below is the reply from the ticket:

"setReportSource method of the viewer can be used to update the report source as following:
<button (click)="viewer1.setReportSource({report: 'assembly-qualified name of the report or path to the file',
parameters: { Parameter1: 'value'}})">Refresh Report</button>

This method expects a JSON object with report(string) and parameters(JSON) properties - Angular Report Viewer Methods."


Regards,
Katia
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Bob
Top achievements
Rank 1
Veteran
answered on 08 May 2019, 11:40 PM
ngOnInit() {
  this.setParameters();
}
 
setParameters(): void {
  this.reportViewer.setReportSource({
    report: 'Residents.trdp',
    parameters: {}
  });
}

This comes up with the error 

Argument of type '{ report: string; }' is not assignable to parameter of type 'JSON'.
  Type '{ report: string; }' is missing the following properties from type 'JSON': parse, stringify, [Symbol.toStringTag]
0
Bob
Top achievements
Rank 1
answered on 08 May 2019, 11:57 PM

I didn't submit this post. It just appeared in email....

 

0
Bob
Top achievements
Rank 1
Veteran
answered on 08 May 2019, 11:59 PM
I'm also called Bob...
0
Bob
Top achievements
Rank 1
Veteran
answered on 09 May 2019, 01:25 PM

For anyone interested The following code was used to cast the reportSource object:

ngAfterViewInit() {
  this.setReportSource();
}
 
setReportSource(): void {
  let rs = {
    report: 'FoodAndFluid.trdp',
    parameters: {
      NcEntityId: this.id,
      From: this.range.From,
      To: this.range.To
    }
  } as unknown as JSON;
  this.viewer.setReportSource(rs);
}
0
Silviya
Telerik team
answered on 13 May 2019, 10:58 AM
Hi Bob,
 
Thank you for bringing this issue to our attention. We consider this as a bug and it is already logged to our Public Feedback and Ideas portal on your behalf (Angular Report Viewer Report Source Update throws an error). 

Thank you also for coming up with a possible workaround.

Best Regards,
Silviya
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Bob
Top achievements
Rank 1
Answers by
Katia
Telerik team
Bob
Top achievements
Rank 1
Veteran
Bob
Top achievements
Rank 1
Silviya
Telerik team
Share this question
or