Page 1 of 1

Set Report Culture With Variable Expression

Posted: Wed Mar 06, 2024 12:57 pm
by servitux
Hi.

I have a report, with a variable named CULTURE, with value "es-ES". The expression used in Report Culture Property is {CULTURE}

In Stimulsoft Designer, report renders fine. If we change CULTURE value to "en-US", reports shows english translations on preview. That's fine.

But, when I launch the report from PHP, and I set the CULTURE value to "en-US" in onPrepareVariables event, variable is set with value "en-US" successfully (we show value in report detail and it shows "en-US"), but report not render in English. We try with AutoLocalizeReportOnRun set to true and to false, with the same result.

What's is wrong?

Thanks.

Image
Image
Image
Image

Re: Set Report Culture With Variable Expression

Posted: Wed Mar 06, 2024 1:14 pm
by Max Shamanov
Hello,

Please send us a sample report with test data that reproduces the issue.

Thank you.

Re: Set Report Culture With Variable Expression

Posted: Wed Mar 06, 2024 2:20 pm
by servitux
Hi, thanks for your faster awnser.

Problem exists with sample report with json datasource and 3 columns with 3 rows, and with a complex report with headers, 3 datasources, etc... the problem is not the report, I think... Designer is working, but not the Viewer from PHP.

JS report object needs a method or property set to another value to do the translation before the render?

Thanks

Re: Set Report Culture With Variable Expression

Posted: Wed Mar 06, 2024 2:39 pm
by servitux
More info: I'm using Laravel 10. Do the report viewer needs a special route or ignore crsf token?

Re: Set Report Culture With Variable Expression

Posted: Wed Mar 06, 2024 3:44 pm
by servitux
Hi again.

I have been doing some tests, and I have solved it as follows:

In PHP:
onPrepareVariables event, I fill {CULTURE} variable, but this value does not make it to the report, or does not take it into account, although it is shown in the detail section (????)


In <script> section on viewer:

Code: Select all

<script type="text/javascript">
    <?php
      $handler->renderHtml();
    ?>

    function onBeforeRender(event)
    {
      var variable = event.report.dictionary.variables.getByName('CULTURE')
      console.debug(variable.value); //CULTURE IS NOT SET YET! ???
      if (variable) variable.value = "{{$culture}}";
      console.debug(variable.value); //CULTURE IS NOW SET AND REPORTS RENDERS SUCCESSFULLY
    }

    function onLoad() {
      <?php
        $viewer->renderHtml('viewerContent');
      ?>
    }
</script>
In this JS block, CULTURE variable not yet have the value of the established culture on PHP onPrepareValues event (???), but if we fill the value now, then it works.

Could be a bug in the onPrepareVariables event???

Thanks

Re: Set Report Culture With Variable Expression

Posted: Thu Mar 07, 2024 9:20 am
by Max Shamanov
Hello,

Thank you for the imformation.
We need some time to investigate the issue. We will let you know about the result.

Thank you.

Re: Set Report Culture With Variable Expression

Posted: Tue May 14, 2024 6:59 am
by Mangona
The issue you're facing could be related to the way the report is being rendered on the server-side (in your PHP application) versus the way it's being rendered in the Stimulsoft Designer.

Re: Set Report Culture With Variable Expression

Posted: Wed May 15, 2024 7:34 am
by Max Shamanov
Hello,

Please send us a sample report with test data that will allow us to reproduce the problem on our side.

Thank you.