ToQueryString Report Problem

Stimulsoft Reports.PHP discussion
Post Reply
minggus
Posts: 4
Joined: Thu Mar 15, 2018 6:32 am

ToQueryString Report Problem

Post by minggus »

i have been work around with this ToQueryString(); report and i'm still facing a problem with the php code
i'm using this php code in my viewer to show the report.

Code: Select all

StiVariable var1 = report.dictionary.variables.getByName("Variable1");
		var1.DialogInfo.Keys = new string[] {"1", "2", "3"};
		var1.DialogInfo.Values = new string[] {"111","222","333"};

		LongList list = new LongList();
		list.AddRange(new long[] {1,2,3});

		report.CompiledReport["Variable1"] = list;

		viewer.report = report;
		viewer.renderHtml("viewerContent");
in my report i already put Variable1 as the variable with string and value as the type.
but i'm still have error in my view report "Uncaught SyntaxError: Unexpected identifier" in this line StiVariable var1 = report.dictionary.variables.getByName("Variable1");
where i do wrong in my code???


thank you
Attachments
ReportDynamicSQLqueries.mrt
(21.05 KiB) Downloaded 262 times
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: ToQueryString Report Problem

Post by Alex K. »

Hello,

Please check the following code:

Code: Select all

var newVariable = new Stimulsoft.Report.Dictionary.StiVariable();
newVariable.name = "Variable";
newVariable.alias = "Variable";
newVariable.type = Stimulsoft.System.StimulsoftStringList;
newVariable.requestFromUser = true;

var di = new Stimulsoft.Report.Dictionary.StiDialogInfo();
di.allowUserValues = false;
di.keys = ["1", "2", "3", "4"];
di.values = ["1", "2", "3", "4"];

newVariable.dialogInfo = di;

report.dictionary.variables.add(newVariable);
designer.onPreviewReport = function (args) {
  args.report.setVariable("Variable", ["1", "4"]);}
Thank you.
minggus
Posts: 4
Joined: Thu Mar 15, 2018 6:32 am

Re: ToQueryString Report Problem

Post by minggus »

thank you mr. Alex but i still have an error on the php view

Code: Select all

    Uncaught ReferenceError: designer is not defined  at viewerDynamic.php:176
    designer.onPreviewReport = function (args) {

here my full code :

Code: Select all

		var options = new Stimulsoft.Viewer.StiViewerOptions();
		options.appearance.fullScreenMode = true;
		options.toolbar.showSendEmailButton = true;
		
		var viewer = new Stimulsoft.Viewer.StiViewer(options, "StiViewer", false);
		
		// Process SQL data source
		viewer.onBeginProcessData = function (event, callback) {
			<?php StiHelper::createHandler(); ?>
		}
		
		// Manage export settings on the server side
		viewer.onBeginExportReport = function (args) {
			<?php //StiHelper::createHandler(); ?>
			//args.fileName = "MyReportName";
		}
		
		// Process exported report file on the server side
		/*viewer.onEndExportReport = function (event) {
			event.preventDefault = true; // Prevent client default event handler (save the exported report as a file)
			<?php StiHelper::createHandler(); ?>
		}*/
		
		// Send exported report to Email
		viewer.onEmailReport = function (event) {
			<?php StiHelper::createHandler(); ?>
		}
		
		// Load and show report
		var report = new Stimulsoft.Report.StiReport();
		//report.loadFile("reports/"+"<?php echo $reportname?>"+".mrt");
		report.loadFile("reports/ReportDynamicSQLqueries.mrt");
		report.dictionary.databases.getByIndex(0).connectionString = '<?=$connStr?>';		

		
		var newVariable = new Stimulsoft.Report.Dictionary.StiVariable();
		newVariable.name = "Variable1";
		newVariable.alias = "Variable1";
		newVariable.type = Stimulsoft.System.StimulsoftStringList;
		newVariable.requestFromUser = true;

		var di = new Stimulsoft.Report.Dictionary.StiDialogInfo();
		di.allowUserValues = false;
		di.keys = ["1", "2", "3", "4"];
		di.values = ["1", "2", "3", "4"];

		newVariable.dialogInfo = di;

		report.dictionary.variables.add(newVariable);
		designer.onPreviewReport = function (args) {
		  args.report.setVariable("Variable1", ["1", "4"]);}

		viewer.report = report;
		viewer.renderHtml("viewerContent");
Lech Kulikowski
Posts: 6197
Joined: Tue Mar 20, 2018 5:34 am

Re: ToQueryString Report Problem

Post by Lech Kulikowski »

Hello,

Sorry for the misunderstanding, Alex provides code for the designer.
Please try to check the following code:

Code: Select all

...
report.dictionary.variables.add(newVariable);
report.setVariable("Variable", ["1", "4"]);
...
viewer.report = report;
viewer.renderHtml("viewerContent");
Thank you.
minggus
Posts: 4
Joined: Thu Mar 15, 2018 6:32 am

Re: ToQueryString Report Problem

Post by minggus »

Lech Kulikowski wrote:Hello,

Sorry for the misunderstanding, Alex provides code for the designer.
Please try to check the following code:

Code: Select all

...
report.dictionary.variables.add(newVariable);
report.setVariable("Variable", ["1", "4"]);
...
viewer.report = report;
viewer.renderHtml("viewerContent");
Thank you.
Great,
this is the right solution

thank you mr. Lech
Lech Kulikowski
Posts: 6197
Joined: Tue Mar 20, 2018 5:34 am

Re: ToQueryString Report Problem

Post by Lech Kulikowski »

Hello

We are always glad to help you!
Please let us know if you need any additional help.

Thank you.
minggus
Posts: 4
Joined: Thu Mar 15, 2018 6:32 am

Re: ToQueryString Report Problem

Post by minggus »

Lech Kulikowski wrote:Hello

We are always glad to help you!
Please let us know if you need any additional help.

Thank you.
Sorry , but i facing new problem my report only show when i pass only one on my array, and when i pass more than one value inside my array
my report not showing any data.

this my report parameter varibale1
Image

and this my query
Image

where do i made something wrong??

thankyou
Lech Kulikowski
Posts: 6197
Joined: Tue Mar 20, 2018 5:34 am

Re: ToQueryString Report Problem

Post by Lech Kulikowski »

Hello,

Please send us a sample report with test data which reproduces the issue for analysis.

Also, please check which query sends to the database server.

Thank you.
Post Reply