Creating and Editing Reports
To run the designer without a report you don't need to make any actions. To load a component, the main menu of the designer will be displayed. If you need to run the designer with a new report, you can create a new object of the StiReport report and assign it to the designer. In addition, you can preload data for a new report or make some other necessary actions.
To edit a report in the designer, you should create the StiReport object, load a report template to it and assign the resulting object to the designer. All other actions will be made automatically, the designer will display the first page of the template.
designer.php |
<?php $designer = new \Stimulsoft\Designer\StiDesigner(); $report = new \Stimulsoft\Report\StiReport(); $report.loadFile('reports/SimpleList.mrt'); $designer->report = $report; $designer->renderHtml(); ?>
|
The designer can work with standard, packed, and encrypted templates. You can find a detailed description of work with various report formats in the Loading and Saving Reports chapter.
A new report can be created using the main menu of the designer. To preload data for a new report or make some other necessary actions with a new report, you should use the onCreateReport event. This event will be invoked when creating a new blank report from the main menu or report creation using the master. For example, when creating a new report you need to connect data to it and synchronize them with data dictionary.
designer.php |
<?php $designer = new \Stimulsoft\Designer\StiDesigner(); $designer->onCreateReport = 'onCreateReport'; $designer->renderHtml(); ?>
function onCreateReport(args) { var dataSet = new Stimulsoft.System.Data.DataSet("SimpleDataSet"); dataSet.readJsonFile("Data/Demo.json");
args.report.regData(dataSet.dataSetName, "", dataSet); args.report.dictionary.synchronize(); }
|
If needed, you can control the process of creation a new report on the PHP server-side. To do it you should add the invoke of the event handler on the client-side and define the onCreateReport event of the same name in the event handler file. You can find a detailed description of work of events in the PHP Events Handler chapter.
designer.php |
<?php $designer = new \Stimulsoft\Designer\StiDesigner(); $designer->onCreateReport = true; $designer->renderHtml(); ?>
|
handler.php |
$handler->onCreateReport = function ($args) { $report = $args->report;
return \Stimulsoft\StiResult::success(); };
|
In arguments of the event a report object created in the designer will be transferred. If needed, you can change it or load a new report. After the event completed, this report will be automatically loaded to the designer to edit. For example, you need to preload a prepared template with embedded connections to data when creating a new report in the designer.
handler.php |
$handler->onCreateReport = function ($args) { $args->report = file_get_contents('reports/NewTemplateWithData.mrt');
return \Stimulsoft\StiResult::success(); };
|
You can find a detailed description of available values of arguments in the Designer Events chapter.