Saving a Report Template in the Designer
Our sample projects and report templates can help you learn the basics of working with our products.When you host the web designer you usually want to control where edited templates are stored.
Enabling save. Register a
Handling the save. In the action you receive the edited report and the file name from the Save dialog, and store the template yourself — here it is serialized to a JSON string:
Because you get the report object and the requested name, the template can be written to a database, a cloud store or the file system — the designer only needs a confirmation message in return.
Enabling save. Register a
SaveReport action in the designer options:@Html.StiNetCoreDesigner(new StiNetCoreDesignerOptions()
{
Actions =
{
GetReport = "GetReport",
SaveReport = "SaveReport",
DesignerEvent = "DesignerEvent"
}
})Handling the save. In the action you receive the edited report and the file name from the Save dialog, and store the template yourself — here it is serialized to a JSON string:
public IActionResult GetReport()
{
var report = new StiReport();
report.Load(StiNetCoreHelper.MapPath(this, "Reports/TwoSimpleLists.mrt"));
return StiNetCoreDesigner.GetReportResult(this, report);
}
public IActionResult SaveReport()
{
var requestParams = StiNetCoreDesigner.GetRequestParams(this);
var report = StiNetCoreDesigner.GetReportObject(this);
// Save the report template, for example to a JSON string
var json = report.SaveToJsonString();
var name1 = report.ReportName; // Original report name
var name2 = requestParams.Designer.FileName; // Name from the Save dialog
return Content($"{{\"infoMessage\":\"Report file saved successfully as {name2}\"}}");
}Because you get the report object and the requested name, the template can be written to a database, a cloud store or the file system — the designer only needs a confirmation message in return.