Page 1 of 1

Capture Empty Datasource in Viewer

Posted: Fri Jan 17, 2025 5:09 pm
by servitux
How can I capture event in which I can check if datasource is empty?

On Report.onBeginRender is not possible. isEmpty from dictionario.datasources.getByIndex(0) return true, but it has rows. There is any event on I can check this values?

Thansk. This is my html:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>{{$title}} - {{config('app.name')}}</title>

<?php
$js->renderHtml();
?>

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

function onBeforeRender(event)
{
console.debug(event.report); <--- here event.report.dictionario.datasources.getByIndex(0).isEmpty return true

}

function onLoad() {
<?php
$viewer->renderHtml('viewerContent');
?>
}
</script>
</head>

<body onload="onLoad();">
<div id="viewerContent"></div>
</body>
</html>

Re: Capture Empty Datasource in Viewer

Posted: Mon Jan 20, 2025 9:17 am
by Lech Kulikowski
Hello,

What data sources are you use in your report - is it file XML, JSON or SQL sources?

Thank you.

Re: Capture Empty Datasource in Viewer

Posted: Tue Jan 21, 2025 10:39 am
by servitux
Hi.

SQL Source. MySQL indeed

Re: Capture Empty Datasource in Viewer

Posted: Tue Jan 21, 2025 11:35 pm
by Lech Kulikowski
Hello,

Please try to check the onEndProcessData event:
https://www.stimulsoft.com/en/documenta ... l_data.htm

Thank you.

Re: Capture Empty Datasource in Viewer

Posted: Wed Jan 22, 2025 12:13 pm
by servitux
Hi, thanks for reply

But, where? in HTML / Javascript I can't capture onEndProcessData. How can i do it? I try to update my php StiReport object with $this->onEndProcessData = true, at the same way with onBeginRender event, the event onEndProcessData never fires.

In addition, the viewer, after render, fires an alert with this message: "Unknown event [EndProcessData]"

My HTML:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>{{$title}} - {{config('app.name')}}</title>

<?php
$js->renderHtml();
?>

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

function onBeforeRender(event)
{
var variable = event.report.dictionary.variables.getByName('CULTURE')
if (variable) variable.value = "{{$report->culture}}";
}

function onEndProcessData(event)
{
console.debug(event.report); <--------------------- this never fires
}

function onLoad() {
<?php
$viewer->renderHtml('viewerContent');
?>
}
</script>
</head>

<body onload="onLoad();">
<div id="viewerContent"></div>
</body>
</html>

Re: Capture Empty Datasource in Viewer

Posted: Wed Jan 22, 2025 8:48 pm
by Lech Kulikowski
Hello,

Please check the following samples:
https://github.com/stimulsoft/Samples-Reports.PHP

Thank you.

Re: Capture Empty Datasource in Viewer

Posted: Sat Jan 25, 2025 6:41 pm
by servitux
Hi. Thanks for reply.

In my case, my version of library was 2023.4. I've updated to 2025.1 and now, with server side rendering and new report/viewer classes all is more easy.

I'm going to close this thread, and open another with a server-side rendering and exporting.

Bye.

Re: Capture Empty Datasource in Viewer

Posted: Mon Jan 27, 2025 11:05 pm
by Lech Kulikowski
Hello,

You are welcome.