Report variables can be assigned on the server before rendering — the onPrepareVariables event supplies values that flow into the report generator.

Set variable values in PHP.
$viewer = new StiViewer();
$viewer->javascript->relativePath = '../';

$viewer->onPrepareVariables = function (StiVariablesEventArgs $args) {
    if (count($args->variables) > 0) {
        $args->variables['Name']->value = 'Maria';
        $args->variables['Surname']->value = 'Anders';
        $args->variables['BirthDay']->value = '1982-03-20 00:00:00';
    }
};

$viewer->process();
$report->loadFile('../reports/Variables.mrt');
$viewer->report = $report;

How it works. Values chosen on the server are injected into the report generator, so the client renders with data it never had to supply.
In the screenshot below you can see the result of the sample code:

Setting Report Variables on the Server-Side

By using this website, you agree to the use of cookies for analytics and personalized content. Cookies store useful information on your computer to help us improve efficiency and usability. For more information, please read the privacy policy and cookie policy.