Page 1 of 2
pattern to open viewer in js
Posted: Sat Dec 05, 2015 10:33 pm
by suyonob
hello, would you describe how to show report in viewer in js.
in faq described only flash.
Re: pattern to open viewer in js
Posted: Mon Dec 07, 2015 6:16 am
by HighAley
Hello.
You could find a sample in c:\Users\Public\Documents\Stimulsoft Samples 2015.3\Stimulsoft Reports.PHP\JS\ folder.
Please, look at the viewer.php file.
Thank you.
Re: pattern to open viewer in js
Posted: Mon Dec 07, 2015 10:04 am
by suyonob
thank you.
in flash. to open report in viewer have address :
http://localhost/stimulsoft/index.php?s ... Report.mrt
how to accomplish this way when using js ?
Re: pattern to open viewer in js
Posted: Mon Dec 07, 2015 1:47 pm
by HighAley
Hello.
Sorry, maybe we don't understand your question.
Could you describer your issue more detailed?
Thank you.
Re: pattern to open viewer in js
Posted: Mon Dec 07, 2015 9:43 pm
by suyonob
i mean i want to know how to open report in viewer using js like in flash.
below are attachment that i captured from faq of stimulsoft php.
thank you
Re: pattern to open viewer in js
Posted: Tue Dec 08, 2015 11:00 am
by Vladimir
Hello,
JS PHP product is more universal in use than Flash, so the usage scenarios are different. You can use the following code to work with the report using JavaScript object StiReport:
index.php
Code: Select all
var report = new Stimulsoft.Report.StiReport();
report.loadFile("getreport.php?id=<?php echo $report_id; ?>");
getreport.php
Code: Select all
<?php
$report_id = $_GET["id"];
$file = "reports/$report_id.mrt";
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/json');
header('Content-Disposition: attachment; filename="'.basename($file).'"');
header('Content-Length: '.filesize($file));
readfile($file);
exit;
}
?>
Thank you.
Re: pattern to open viewer in js
Posted: Thu Dec 10, 2015 5:03 am
by suyonob
thank you.
yes i got using js. and what about using parameter. what should i do ?
Re: pattern to open viewer in js
Posted: Thu Dec 10, 2015 12:24 pm
by Vladimir
Hello,
You can assign parameters from URL to the report as follows:
Code: Select all
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,
function (m, key, value) {
vars[key] = value;
});
return vars;
}
var vars = getUrlVars();
report.dictionary.variables.list.forEach(function(item, i, arr) {
if (typeof vars[item.name] != "undefined") item.valueObject = vars[item.name];
});
viewer.report = report;
Also, you can optionally add code to validate the values of variables in accordance with your requirements.
Thank you.
Re: pattern to open viewer in js
Posted: Tue Dec 15, 2015 1:20 am
by suyonob
thank you.
would you like to explain to us line by line how to add/insert parameter into your code above ?
and i have try to write sql from js designer but when i addedd parameter, there can not saved.
thank you very much
Re: pattern to open viewer in js
Posted: Wed Dec 16, 2015 6:14 am
by HighAley
Hello.
This code takes all parameters from URL and set values of variables if it exists in the report with the same name.
Could you describe your issue more detailed? Who do you add the parameter?
Thank you.