Menu
Download Free Trial
Table of contents

save

save(params:Object)

[starting from version: 2.302]

You can use this method to save your current report to a specified location. Thus you can open it later with all fields, applied filters, and sortings same like you placed it. This method saves report in JSON format. XML reports are also supported in terms of backward compatibility.

Parameters

params object can have the following properties:

  • filename – a default name of the file.
  • destination (optional) – parameter defines how to save a generated file. File can be saved to "server" or "file". The default value is "file".
  • callbackHandler (optional) – JS function which will be called when the report is saved.
  • url (optional) – an URL to the server-side script which saves the generated file. The file is sent as a POST parameter. Use this parameter only if destination parameter is "server".
  • embedData (optional) – specifies whether to save CSV/OCSV data within the report or not. Default value is false.
  • reportType (optional) – String. Report can be saved in "json" or "xml" format. Default value is "json".

Examples

How to save a report to the local file system:

flexmonster.save({
    filename: 'myreport.json', 
    destination: 'file'
});

How to save a report to the server:

flexmonster.save({
    filename: 'myreport.json', 
    destination: 'server',
    url: 'http://yourserver.com/yourscript.php'
});

Please note that the server-side script should be created on your back-end to be able save reports to the server. And an url parameter is the path to this server-side script.

How to save a report and perform some JS code right after the report was already saved:

<button onclick="javascript: 
    flexmonster.save({
    filename: 'myreport.json', 
    destination: 'file',
    callbackHandler: 'reportSaved'
})">
	Save Report
</button>
<script type="text/javascript">
	function reportSaved() {
	// some JS code 
	}
</script>

See also

load
getReport
setReport