Angular Report: ExportReport action not called.
Posted: Tue Jan 19, 2021 7:16 pm
Hello,
I have created a report page using the new Angular libraries and i've been running into some issues. The latest issue is the action ExportReport is never sent back to the server when trying to save the report in any format. Print Preview and Print works, but when I select PDF from the print dropdown, the client side makes the POST request that is not captured by my interceptors so the request gets sent to the UI endpoint and not the server endpoint.
The page allows the user to select a report from the drop down and apply filters. Once the user clicks 'Run Report', the filters and report filename is placed in the 'properties' of the request and parsed on the server side. Here is the function for 'Run Report'
this is where the component/viewchild is defined in the html template. [note] i know the url is missing from this, it is intentional so the report UI does not populate until the user clicks 'run report'
Here is the server side that handles the client requests
I have placed breakpoints on the ViewerEvent to inspect the received actions, I also inspected the web traffic using Fiddler and I do not see any requests for exporting from the client. In an attempt to remedy the print to pdf action issue, I tried including the baseurl in the this.stiViewer.requestUrl statement, but this caused another error to prompt stating 'unable to read 'Method' of null' and I wasn't able to run the report at all.
front end versions
-initial
-stimulsoft-reports-js 2020.5.1
-stimulsoft-viewer-angular: 2020.5.1-b
-current
-stimulsoft-reports-js 2021.1.1
-stimulsoft-viewer-angular:2021.1.1
Server version
-Stimulsoft.Reports.Angular.NetCore 2020.5.1
Please let me know if you need any additional information, any help would be great.
I have created a report page using the new Angular libraries and i've been running into some issues. The latest issue is the action ExportReport is never sent back to the server when trying to save the report in any format. Print Preview and Print works, but when I select PDF from the print dropdown, the client side makes the POST request that is not captured by my interceptors so the request gets sent to the UI endpoint and not the server endpoint.
The page allows the user to select a report from the drop down and apply filters. Once the user clicks 'Run Report', the filters and report filename is placed in the 'properties' of the request and parsed on the server side. Here is the function for 'Run Report'
Code: Select all
@ViewChild('stiViewer') stiViewer: StimulsoftViewerComponent;
// ...
// ...
runReport(){
this.reportViewerActive = true;
this.reportSettings.template = this.activeSettings.selectedReport;
this.applyFilters(); //takes the filters from the user and compiles this.reportSettings
this.stiViewer.properties = this.reportSettings;
this.stiViewer.requestUrl = `/api/Stimulsoft/${this.locationId}/{action}`;
this.stiViewer.action='InitViewer';
this.stiViewer.ngOnChanges(null); //triggers the stimulsoft component to update after assigning the url
}
Code: Select all
<div class="flex-item flex-grow" style="min-height: 100%;">
<stimulsoft-viewer-angular
#stiViewer
height="75vh" ></stimulsoft-viewer-angular>
</div>
Code: Select all
[HttpPost("{location}/InitViewer")]
public IActionResult InitViewer([FromRoute]int location)
{
var requestParams = StiAngularViewer.GetRequestParams(this);
var options = new StiAngularViewerOptions();
options.Actions.ViewerEvent = "ViewerEvent";
options.Appearance.ScrollbarsMode = true;
options.Exports.ShowExportDialog = false;
options.Server.CacheMode = StiServerCacheMode.ObjectSession;
StiAngularViewer.CacheHelper = new ScaleitStiCache();
return StiAngularViewer.ViewerDataResult(requestParams, options);
}
[HttpPost("{location}/ViewerEvent")]
public IActionResult ViewerEvent([FromRoute]int location, [FromForm]string properties)
{
var requestParams = StiAngularViewer.GetRequestParams(this);
if (requestParams.Action == StiAction.GetReport)
{
var reportProperties = this.parseProperties(properties);
var stiReport = this.getTemplate(location, reportProperties);
stiReport = this.setTemplateConnection(location, stiReport);
stiReport = this.setTemplateVariables(stiReport, reportProperties);
return StiAngularViewer.GetReportResult(this, stiReport);
}
return StiAngularViewer.ProcessRequestResult(this);
}
front end versions
-initial
-stimulsoft-reports-js 2020.5.1
-stimulsoft-viewer-angular: 2020.5.1-b
-current
-stimulsoft-reports-js 2021.1.1
-stimulsoft-viewer-angular:2021.1.1
Server version
-Stimulsoft.Reports.Angular.NetCore 2020.5.1
Please let me know if you need any additional information, any help would be great.