Hello,
About the example Setting Report Variables on the Server-Side, the values for variables are ok.
Example
Name = 'Maria' Because in the
handler.php
$args->variables['Name']->value = 'Maria';
When I want to modify in design the same report Variables.mrt
The initial value of the Name is =""
I want to see the current value that updates it in handler.php Name='Maria'
If in the design I update the variable Name = "Maria12345" in the preview it shows only the Maria the original value changed in the handler.
What should I do?
Thank you.
Setting Report Variables on the Server-Side
-
- Posts: 850
- Joined: Tue Sep 07, 2021 10:11 am
Re: Setting Report Variables on the Server-Side
Hello,
When you change variable value in design time, it changes back when retrieve data from the server.
Could you explain your issue in more detail?
Thank you.
When you change variable value in design time, it changes back when retrieve data from the server.
Could you explain your issue in more detail?
Thank you.
Re: Setting Report Variables on the Server-Side
Hello,
I use the Stimulsoft 2019
The example code is the follows:
09. Set variable value from code
In the viewer, the value is ok -> test
In the designer, the value of Variable1 is -> default
In the preview, it is the same value -> default
I can update any value for Variable1 and the preview changes too.
*****************************************
But I have the other code that is better for me.
In the 2019 preview version for JS, I used the following code, I can create the variables or update the values. Viewer the value is -> Val-ggs
The designer is the same value -> Val-ggs
In preview, is the same value -> Val-ggs
I can update any value for Variable1 and the preview changes too.
It's useful because whether or not you create the variables, the code creates the variables and updates the values.
**********************
In JS is working but the PHP code not is working.
How can I get the same behavior in the following code PHP?
<script type="text/javascript">
<?php
$handler = new StiHandler();
//$handler->license->setFile('license.key');
$handler->renderHtml();
/** https://www.stimulsoft.com/en/documenta ... ttings.htm */
$options = new StiViewerOptions();
$options->appearance->fullScreenMode = true;
$options->appearance->scrollbarsMode = true;
$options->height = '600px'; // Height for non-fullscreen mode
/** https://www.stimulsoft.com/en/documenta ... oyment.htm */
$viewer = new StiViewer($options);
/** https://www.stimulsoft.com/en/documenta ... report.htm */
$report = new StiReport();
$report->loadFile('reports/SimpleList.mrt');
$viewer->report = $report;
?>
function onLoad() {
<?php
$viewer->renderHtml('viewerContent');
?>
}
</script>
Thank you.
I use the Stimulsoft 2019
The example code is the follows:
09. Set variable value from code
In the viewer, the value is ok -> test
In the designer, the value of Variable1 is -> default
In the preview, it is the same value -> default
I can update any value for Variable1 and the preview changes too.
*****************************************
But I have the other code that is better for me.
In the 2019 preview version for JS, I used the following code, I can create the variables or update the values. Viewer the value is -> Val-ggs
The designer is the same value -> Val-ggs
In preview, is the same value -> Val-ggs
I can update any value for Variable1 and the preview changes too.
It's useful because whether or not you create the variables, the code creates the variables and updates the values.
**********************
In JS is working but the PHP code not is working.
How can I get the same behavior in the following code PHP?
<script type="text/javascript">
<?php
$handler = new StiHandler();
//$handler->license->setFile('license.key');
$handler->renderHtml();
/** https://www.stimulsoft.com/en/documenta ... ttings.htm */
$options = new StiViewerOptions();
$options->appearance->fullScreenMode = true;
$options->appearance->scrollbarsMode = true;
$options->height = '600px'; // Height for non-fullscreen mode
/** https://www.stimulsoft.com/en/documenta ... oyment.htm */
$viewer = new StiViewer($options);
/** https://www.stimulsoft.com/en/documenta ... report.htm */
$report = new StiReport();
$report->loadFile('reports/SimpleList.mrt');
$viewer->report = $report;
?>
function onLoad() {
<?php
$viewer->renderHtml('viewerContent');
?>
}
</script>
Thank you.
-
- Posts: 850
- Joined: Tue Sep 07, 2021 10:11 am
Re: Setting Report Variables on the Server-Side
Hello,
Unforunately, at the current moment you can't create a variable using php code.
We are working on this issue.
But you can use JS code to create a variable and use it.
Please check the following link:
https://github.com/stimulsoft/Samples-J ... Script.php
Thank you.
#9758
Unforunately, at the current moment you can't create a variable using php code.
We are working on this issue.
But you can use JS code to create a variable and use it.
Please check the following link:
https://github.com/stimulsoft/Samples-J ... Script.php
Thank you.
#9758
-
- Posts: 850
- Joined: Tue Sep 07, 2021 10:11 am
Re: Setting Report Variables on the Server-Side
Hello,
You can add a new variable to report by using the following code in PHP:
Unfortunately, it is not possible to change or delete varibale via PHP code.
If you need to edit, or add with advanced properties - this is all available in JavaScript code in the report event onBeforeRender:
...
Thank you.
You can add a new variable to report by using the following code in PHP:
Code: Select all
$var1 = new \Stimulsoft\Report\StiVariable('var1', \Stimulsoft\Report\StiVariableType::String, "abc");
$report->dictionary->variables[] = $var1;
$var2 = new \Stimulsoft\Report\StiVariable('var2', \Stimulsoft\Report\StiVariableType::Decimal, 4.34);
$report->dictionary->variables[] = $var2;
If you need to edit, or add with advanced properties - this is all available in JavaScript code in the report event onBeforeRender:
Code: Select all
$report->onBeforeRender = "onBeforeRender";
Code: Select all
function onBeforeRender(args) {
let var1 = new Stimulsoft.Report.Dictionary.StiVariable('', 'var1', 'var1', '', Stimulsoft.System.Decimal, '4.34');
args.report.dictionary.variables.add(var1);
}