Saving a Report Template on the Server-Side
Our sample projects and report templates can help you learn the basics of working with our products.When the user saves in the designer, the template is sent to the server, where the
Persist the template in the event.
How it works. The designer round-trips the template through the Python event, so user edits are stored wherever your app chooses.
onSaveReport event decides how to store it.Persist the template in the event.
def saveReport(args: StiReportEventArgs):
filePath = os.path.normpath(os.getcwd() +
url_for('static', filename='reports/' + args.fileName))
with open(filePath, mode='w', encoding='utf-8') as file:
file.write(json.dumps(args.report, indent=4))
return f'The report was saved to {args.fileName}.'
designer.onSaveReport += saveReportonSaveReport— fires on manual or automatic save;args.reportis the edited template,args.fileNameits name.json.dumps(args.report)— serialize the template to JSON and write it to disk.
How it works. The designer round-trips the template through the Python event, so user edits are stored wherever your app chooses.