Hi everyone
I have a problem with visualise.js not producing report export file. What happens is:
- I am able to succsefully load the report through the visualise.js API, it loads and displays on my web page
- Export controls load up successfully too, so I have dropdown with export file formats and a button to export the file.
- When I click the export button though, the whole page reloads as if the export button was really a submit button and nothing happens.
- Weird thing is that occasionally, the export will work and it will produce file. Though there is no pattern to when it will produce the file and when it will fail.
Below is the code I am using for this (I am using plain text auth for testing purposes):
JS:
visualize({ auth: { name: "mylogin", password: "mypass", organization: "organization_1" } }, function (v) { var $select = buildControl("Export to: ", v.report.exportFormats), $button = $("#button"), report = v.report({ resource: "/FPSReports/journal", container: "#export", params: { "journal_ref": [ "<?php echo $reference; ?>" ], }, success: function () { button.removeAttribute("disabled"); }, error : function (error) { console.log(error); } }); $button.click(function () { console.log($select.val()); report.export({ // export options here outputFormat: $select.val(), // exports all pages if not specified // pages: "1-2" }, function (link) { var url = link.href ? link.href : link; window.location.href = url; }, function (error) { console.log(error); }); }); function buildControl(name, options){ function buildOptions(options) { var template = "<option>{value}</option>"; return options.reduce(function (memo, option) { return memo + template.replace("{value}", option); }, "") } var template = "<label>{label}</label><select>{options}</select><br />", content = template.replace("{label}", name) .replace("{options}", buildOptions(options)); var $control = $(content); $control.insertBefore($("#button")); //return select return $($control[1]); } });
The code above is used to generate the report and to generate the controls.
HTML:
<div class="grid"> <div class="grid-8"></div> <div class="grid-8 center"><a href="" id="button" class="large link_button margin2">Export</a></div> <div class="grid-8"></div> </div> <div class="grid"> <div class="grid-24" id="export"></div> </div>
The report I am exporting is small one page report, it loads in no time. I really do not understand where there could be an issue.
Is this some kind of timeout happening?
Thanks for all the help in advance!
0 Answers:
No answers yet