Page 1 of 2
Variable categories from code
Posted: Mon Jan 07, 2019 9:37 am
by rpotyka
Hi,
I want to allow user to add variables to the report that are bound to category previously prepared in code (f.e. Tranlsations category). Later on when exporting the report to, say, pdf document, I'd like to iterate through all of the report variables, and when the category is "Translations" I want to do some operation like string localisation. Is there any way to do so? I checked the documentation but there's no method to add category of itself ( I tried method regBusinessObject2 but it didn't do anything or at least I did not notice so.
Thanks in advance,
Kind regards.
Re: Variable categories from code
Posted: Mon Jan 07, 2019 2:27 pm
by Lech Kulikowski
Hello,
Could you explain your issue in more details? How do you need add variables - in code or in the designer? if in the designer, you can add the category for variables directly in the Dictionary.
Thank you.
Re: Variable categories from code
Posted: Wed Jan 09, 2019 2:58 pm
by rpotyka
As the topic says I wanted to add category from code so the user won't have to it themself and to ensure that the name is gonna be consistent for that category throughout ther reports (otherwiso user could just made a typo).
I found the solution however and it's to add variable from code when preparing report by creating new StiVariable and passing "Translation" category in the constructor. Then I just assign this variable via report.dictionary.variables.add method.
The category is then present on the designer and user can add new variables to that category without having to create it themselves.
Re: Variable categories from code
Posted: Wed Jan 09, 2019 11:17 pm
by Lech Kulikowski
Hello
Ok.
Please let us know if you need any additional help.
Thank you.
Re: Variable categories from code
Posted: Fri Jan 18, 2019 2:55 pm
by gegar
Hello
Someone have a example about this code.
Try this and it does not work.
// Load and show report
Stimulsoft.Base.Localization.StiLocalization.setLocalizationFile("localization/en.xml", true);
var report = new Stimulsoft.Report.StiReport();
report.loadFile("reports/report.mrt");
// New variable Address
var variables = new Stimulsoft.Report.Dictionary.StiVariable();
variables.name = "Address";
variables.alias = "Address";
variables.type = Stimulsoft.System.StimulsoftStringList;
variables.requestFromUser = false;
variables.value = "1234 Address ";
viewer.report = report;
Whay is my error.
Thank you.
Re: Variable categories from code
Posted: Fri Jan 18, 2019 2:58 pm
by Lech Kulikowski
Hello,
Please try to add the following code:
report.dictionary.variables.add(variables );
Thank you.
Re: Variable categories from code
Posted: Sat Jan 19, 2019 11:16 pm
by gegar
Hello
// Load and show report
Stimulsoft.Base.Localization.StiLocalization.setLocalizationFile("localization/en.xml", true);
var report = new Stimulsoft.Report.StiReport();
report.loadFile("reports/report.mrt");
var variables = new Stimulsoft.Report.Dictionary.StiVariable();
variables.name = "Address";
variables.alias = "Address";
variables.Type = Stimulsoft.System.StimulsoftType;
variables.requestFromUser = false;
variables.value = "1234 Address ";
report.dictionary.variables.add(variables);
viewer.report = report;
It's working.
Thank you.
Re: Variable categories from code
Posted: Mon Jan 21, 2019 5:11 pm
by Lech Kulikowski
Hello
We are always glad to help you!
Please let us know if you need any additional help.
Thank you.
Re: Variable categories from code
Posted: Thu Jan 05, 2023 9:23 pm
by gegar
Hello,
I update the new version 2023.
How can I do the same in JS and PHP?
Thanks
Re: Variable categories from code
Posted: Thu Jan 05, 2023 10:15 pm
by Lech Kulikowski