Page 1 of 1
MVC - Is it possible to save .mdc file in the viewer without it downloading
Posted: Thu Feb 07, 2019 7:54 am
by vapour.drops
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
Re: MVC - Is it possible to save .mdc file in the viewer without it downloading
Posted: Thu Feb 07, 2019 9:05 am
by Lech Kulikowski
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.
Re: MVC - Is it possible to save .mdc file in the viewer without it downloading
Posted: Fri Feb 08, 2019 12:25 am
by vapour.drops
When i return StiMvcViewer.ExportReportResult(); this still exports/downloads the document to the client machine.
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();
}
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
Re: MVC - Is it possible to save .mdc file in the viewer without it downloading
Posted: Mon Feb 11, 2019 7:53 am
by Lech Kulikowski
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:
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>
Controller:
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();
}
Thank you.
Re: MVC - Is it possible to save .mdc file in the viewer without it downloading
Posted: Thu Feb 14, 2019 4:35 am
by vapour.drops
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.
Re: MVC - Is it possible to save .mdc file in the viewer without it downloading
Posted: Fri Feb 15, 2019 8:38 am
by Lech Kulikowski
Hello,
You can call saving in MDC format with the following JavaScript method:
jsMvcViewer.postExport("Document", jsMvcViewer.getDefaultExportSettings("Document"));
Thank you.