How to pass js array to variable of list in js code ?

Stimulsoft Reports.JS discussion
Post Reply
kairat
Posts: 3
Joined: Wed Dec 21, 2016 11:39 am

How to pass js array to variable of list in js code ?

Post by kairat »

Hi everybody

I need to dynamically update value of list variable. So how can i do it ?

thanks, Kairat
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: How to pass js array to variable of list in js code ?

Post by Alex K. »

Hello,

You can use 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"]);}
This code will works in last release 2017.1.4
Thank you.
Post Reply