Hello
I want to save an edited version of the mdc file from the viewer. I can see that with the save button I can enable it export documents, however I do not want it to download onto the client's machine. Is there a way to stop this? Or can i create a custom button in the toolbar which will return me the StiReport object?
Thanks
MVC - Is it possible to save .mdc file in the viewer without it downloading
-
- Posts: 3
- Joined: Thu Feb 07, 2019 7:49 am
-
- Posts: 6271
- Joined: Tue Mar 20, 2018 5:34 am
Re: MVC - Is it possible to save .mdc file in the viewer without it downloading
Hello,
You can use the export event in which save the report as you needed:
https://www.stimulsoft.com/en/documenta ... export.htm
Thank you.
You can use the export event in which save the report as you needed:
https://www.stimulsoft.com/en/documenta ... export.htm
Thank you.
-
- Posts: 3
- Joined: Thu Feb 07, 2019 7:49 am
Re: MVC - Is it possible to save .mdc file in the viewer without it downloading
When i return StiMvcViewer.ExportReportResult(); this still exports/downloads the document to the client machine.
Also I only want the user to hit save and not need to select the one option in the dropdownlist (one too many clicks). Is this possible?
Thanks in advance
Code: Select all
public ActionResult ExportReport(string filename)
{
StiReport report = StiMvcViewer.GetReportObject();
var result = StiMvcViewer.ViewerEventResult();
if (report != null)
{
if (!string.IsNullOrEmpty(filename))
{
report.SaveDocument(filename);
}
}
return StiMvcViewer.ExportReportResult();
}
Thanks in advance
-
- Posts: 6271
- Joined: Tue Mar 20, 2018 5:34 am
Re: MVC - Is it possible to save .mdc file in the viewer without it downloading
Hello,
You need to redefine the postExport JavaScript method for the viewer component so as not to send a POST request when exporting a document. This can be done with the following code:
viewer:
Controller:
Thank you.
You need to redefine the postExport JavaScript method for the viewer component so as not to send a POST request when exporting a document. This can be done with the following code:
viewer:
Code: Select all
<script>
jsMvcViewer._postExport = jsMvcViewer.postExport;
jsMvcViewer.postExport = function (format, settings) {
if (format == "Document") {
var data = {
action: "ExportReport",
exportFormat: format,
exportSettings: settings
};
jsMvcViewer.postAjax(jsMvcViewer.options.requestUrl.replace("{action}", jsMvcViewer.options.actions.exportReport), data, jsMvcViewer.postExportDone);
}
else {
jsMvcViewer._postExport(format, settings);
}
}
jsMvcViewer.postExportDone = function (data) {
alert("The document file is saved, the server returned: " + data);
}
</script>
Code: Select all
public ActionResult ExportReport()
{
var requestParams = StiMvcViewer.GetRequestParams();
var report = StiMvcViewer.GetReportObject();
if (requestParams.ExportFormat == StiExportFormat.Document && report != null)
{
//report.SaveDocument(filename);
return Content("SaveOK");
}
return StiMvcViewer.ExportReportResult();
}
-
- Posts: 3
- Joined: Thu Feb 07, 2019 7:49 am
Re: MVC - Is it possible to save .mdc file in the viewer without it downloading
Great thank you that worked however it was still 2 clicks to save one format (mdf) option. In the end we needed to save the mdc file from a button external to the viewer.
-
- Posts: 6271
- Joined: Tue Mar 20, 2018 5:34 am
Re: MVC - Is it possible to save .mdc file in the viewer without it downloading
Hello,
You can call saving in MDC format with the following JavaScript method:
jsMvcViewer.postExport("Document", jsMvcViewer.getDefaultExportSettings("Document"));
Thank you.
You can call saving in MDC format with the following JavaScript method:
jsMvcViewer.postExport("Document", jsMvcViewer.getDefaultExportSettings("Document"));
Thank you.