Page 1 of 1
Show Design New Project
Posted: Mon Mar 24, 2025 9:09 am
by evilcat
Hi,
maybe others have asked, I've searched the forum and couldn't find it.
How can I show the project I designed as a shortcut directly from the home page.
Thank you.
Re: Show Design New Project
Posted: Tue Mar 25, 2025 8:25 am
by Lech Kulikowski
Hello,
Unfortunately, it is not possible in the PHP version at the moment.
We have added this task in our to-do list.
Thank you.
#17016
Re: Show Design New Project
Posted: Mon Apr 07, 2025 9:22 pm
by Lech Kulikowski
Hello,
We have added new onAfterInitialize event, in which you can use any javascript code after designer/viewer components initialization.
It will be available in the next major build 2025.3.1
Code: Select all
$designer = new StiDesigner();
$designer->onAfterInitialize = "
var newReportPanel = designer.jsObject.options.newReportPanel || designer.jsObject.InitializeNewReportPanel();
var customBigButton = designer.jsObject.NewReportPanelButton('customReportButton', 'My Report Button', 'BlankReport.png');
//If you want change button image
//customBigButton.image.src = 'https://www.google.by/images/bran/ding/googlelogo/2x/googlelogo_color_272x92dp.png';
newReportPanel.childNodes[1].addCell(customBigButton);
customBigButton.action = function () {
var fileMenu = this.jsObject.options.menus.fileMenu || this.jsObject.InitializeFileMenu();
fileMenu.changeVisibleState(false);
setTimeout(function () {
//Write your code here
alert('customReportButton was clicked!');
}, 200);
}
";
$designer->process();
Thank you.
Re: Show Design New Project
Posted: Thu Apr 10, 2025 7:17 am
by evilcat
Thank you for the help;
I don't have much knowledge, can you help me where and how to add it?
Code: Select all
<?php
require_once 'vendor/autoload.php';
use Stimulsoft\Designer\StiDesigner;
use Stimulsoft\Events\StiReportEventArgs;
use Stimulsoft\Report\StiReport;
use Stimulsoft\StiResult;
// Creating a designer object and set the necessary javascript options
$designer = new StiDesigner();
//$designer->javascript->relativePath = '../';
$designer->javascript->appendHead('<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon">');
$designer->options->localization = 'tr.xml';
// Defining designer events before processing
// It is allowed to assign a PHP function, or the name of a JavaScript function, or a JavaScript function as a string
// Also it is possible to add several functions of different types using the append() method
$designer->onSaveReport = function (StiReportEventArgs $args)
{
// Getting the correct file name of the report template
$reportFileName = strlen($args->fileName) > 0 ? $args->fileName : 'Report.mrt';
if (strlen($reportFileName) < 5 || substr($reportFileName, -4) !== '.mrt')
$reportFileName .= '.mrt';
// Saving the report file in the 'reports' folder on the server-side
$reportPath = "reports/$reportFileName";
$result = file_put_contents($reportPath, $args->getReportJson());
// If required, it is possible to show a message about success or some error
if ($result === false)
return StiResult::getError('An error occurred while saving the report file on the server side.');
return StiResult::getSuccess("The report has been successfully saved to '$reportPath' file.");
//return StiResult::getSuccess();
};
// Processing the request and, if successful, immediately printing the result
$designer->process();
// Creating a report object
$report = new StiReport();
// Loading a report by URL
// This method does not load the report object on the server side, it only generates the necessary JavaScript code
// The report will be loaded into a JavaScript object on the client side
$report->loadFile('reports/ee.mrt');
// Assigning a report object to the designer
$designer->report = $report;
// Displaying the visual part of the designer as a prepared HTML page
$designer->printHtml();
?>
Re: Show Design New Project
Posted: Thu Apr 10, 2025 7:22 am
by Lech Kulikowski
Hello,
That code will work only after the release 2025.3.1.
Thank you.