Samples

 

You can find a full code of on the GitHub.

 

 

 

To use the product, you should download the ZIP archive of the product from the Downloads page of our site, unpack it, and copy the contents of the /PHP folder to your Web server. This folder is a Web project that contains all the necessary files and resources for the product and samples for working with the viewer and designer.

 

To install the product in an existing project, you should copy the /vendor folder from the /PHP folder to the root directory of the project or use the Composer dependency manager by executing the following console command:

 

console

 

composer require stimulsoft/reports-php

 

 

 

When working with the product, in most cases, it is enough to use only PHP code, which ensures the operation of all the main features. For a more detailed configuration of the product and the use of all features, you must use JavaScript code. Next, two options for using certain features will be described - using PHP and JavaScript functions. Depending on your needs, you may use either the first or the second option.

 

To use the HTML5 component the designer (StiDesigner) in the project you should add specified scripts and styles to the <head> block on the PHP page. You can do this using the StiJavaScript PHP class. In the constructor, you need to specify the type of component to deploy:

 

designer.php

 

<head>

<?php

$js = new \Stimulsoft\StiJavaScript(\Stimulsoft\StiComponentType::Designer);

$js->renderHtml();

?>

</head>

 

 

 

To edit dashboards in the designer, in addition you should add a corresponding script file, which contains all what you need to work with dashboards.

 

designer.php

 

<head>

<script src="vendor/stimulsoft/reports-php/scripts/stimulsoft.reports.js" type="text/javascript"></script>

<script src="vendor/stimulsoft/reports-php/scripts/stimulsoft.viewer.js" type="text/javascript"></script>

<script src="vendor/stimulsoft/reports-php/scripts/stimulsoft.designer.js" type="text/javascript"></script>

<script src="vendor/stimulsoft/reports-php/scripts/stimulsoft.blockly.editor.js" type="text/javascript"></script>

</head>

 

 

 

For dashboards, you need to connect the following package:

 

console

 

composer require stimulsoft/dashboards-php

 

 

 

In the case of using PHP code, all necessary scripts will be included automatically, no code change is required. If you use JavaScript code, you will need to add the appropriate script file containing everything you need to work with dashboards:

 

designer.php

 

<head>

<script src="vendor/stimulsoft/reports-php/scripts/stimulsoft.reports.js" type="text/javascript"></script>

<script src="vendor/stimulsoft/dashboards-php/scripts/stimulsoft.dashboards.js" type="text/javascript"></script>

<script src="vendor/stimulsoft/reports-php/scripts/stimulsoft.viewer.js" type="text/javascript"></script>

<script src="vendor/stimulsoft/reports-php/scripts/stimulsoft.designer.js" type="text/javascript"></script>

<script src="vendor/stimulsoft/reports-php/scripts/stimulsoft.blockly.editor.js" type="text/javascript"></script>

</head>

 

 

Information

 

You can find possible optimization variants of deployment in the Optimization of Scripts Loading chapter.

 

 

 

After that, you can use JavaScript functions to work with the designer. To display the designer on the page, you should create an object of the HTML5 Designer component (StiDesigner) a visual part of the component will be deployed in this place, where this script will be called.

 

designer.php

 

<script type="text/javascript">

<?php

$designer = new \Stimulsoft\Designer\StiDesigner();

$designer->renderHtml();

?>

</script>

 

 

 

Arguments of the designer constructor

The StiDesigner object is created with the help of the Stimulsoft.Designer.StiDesigner() constructor, which can take optional arguments as input, which exert influence over its work. There are three arguments.

 

designer.php

 

<script type="text/javascript">

<?php

$designer = new \Stimulsoft\Designer\StiDesigner($options, $designerId);

$designer->renderHtml();

?>

</script>

 

 

Name

Description

options

It is the set of options found in the Stimulsoft.Designer.StiDesignerOptions class. The options are divided into categories and contains all what you need to set the behavior and appearance of the designer. You can find a detailed description of categories and options in the Designer Settings chapter.

designerId

String identifier of the HTML element of the designer. The "StiDesigner" value is used by default.

 

 

The designer display variants

There are two variants of the designer display: immediately at the location of the script and deferred at the specified HTML element of the page. The second variant can be useful if, for example, you need to create and execute the designer scripts in advance, display the designer by clicking a button, display the designer on a dynamically rendering page and in other cases.

 

To display designer, you should invoke the renderHtml() function of the created object.

 

designer.php

 

<script type="text/javascript">

<?php

$designer = new \Stimulsoft\Designer\StiDesigner();

$designer->renderHtml();

?>

</script>

 

 

 

When invoking renderHtml() function, a visual part of the designer will be rendered in an HTML page, where this function is invoked. If needed, you can display the designer inside a definite HTML element. In this case, you should transfer ID of this element or the link to the element as function argument.

 

designer.php

 

<script type="text/javascript">

<?php

$designer = new \Stimulsoft\Designer\StiDesigner();

$designer->renderHtml('designerContent');

?>

</script>

 

<body>

<div id="designerContent"></div>

</body>