Hello,
thank you for your help.
I tried what you suggested and it worked fine for the most part. But I still have a problem: After displaying and editing the report
by the user he clicks the custom-button to call the postExport-Method. The report is post back to the server and there saved to a
pdf-file. But in this file, the changes he made to the report are missing in the file created on the server. Only after he clicks
the custom button a second time, the pdf-file is overwritten and the changes appear in the document.
Here is what I did:
In the view I have added the following script to create a custom button that, when clicked, calls the postExport-Method of the viewer:
Code: Select all
<script type="text/javascript">
jsMvcViewer.SetEditableMode(true);
var customButton = jsMvcViewer.SmallButton("customButton", "Custom Button", "emptyImage");
customButton.image.src = "https://www.stimulsoft.com/favicon.png";
customButton.action = function ()
{
var exportFormat = "Pdf";
var exportSettings = jsMvcViewer.getDefaultExportSettings(exportFormat);
jsMvcViewer.postExport(exportFormat, exportSettings);
}
var toolbarTable = jsMvcViewer.controls.toolbar.firstChild.firstChild;
var buttonsTable = toolbarTable.rows[0].firstChild.firstChild;
var customButtonCell = buttonsTable.rows[0].insertCell(0);
customButtonCell.appendChild(customButton);
</script>
I have also added the necessary options:
Code: Select all
@Html.Stimulsoft().StiMvcViewer(new StiMvcViewerOptions()
{
Actions =
{
GetReport = "GetReport",
ViewerEvent = "ViewerEvent",
ExportReport = "ExportReport",
},
})
On the server side, I have added a handler to the Controller class:
Code: Select all
public ActionResult ExportReport()
{
StiReport report = StiMvcViewer.GetReportObject();
StiRequestParams parameters = StiMvcViewer.GetRequestParams();
if (parameters.ExportFormat == StiExportFormat.Pdf)
{
Stimulsoft.Report.Export.StiPdfExportSettings settings = new Stimulsoft.Report.Export.StiPdfExportSettings();
report.ExportDocument(StiExportFormat.Pdf, Server.MapPath("~/Content/Data/Demo.pdf"));
}
return StiMvcViewer.ExportReportResult(report);
}
When, after editing, the custom button is clicked, the ExportReport() method is called on the server. After the first click, the file saved
on the server (“Demo.pdf”) contains none of the changes mode during editing. Only after the button is clicked a second time, the changes are
written to the file.
Of course, I would prefer my changes do be saved the first time a user presses the custom –button.
I suppose I am doing something wrong. Can you give me a hint, what it is I am missing here?
PS: I also want to suppress the local export in the browser. What kind of ActionResult should I return in the ExportReport()-Method to achieve this.
Best regards,
Scotty