ChartBlocks / php-ssrs

PHP library for connecting to SSRS over SOAP
MIT License
25 stars 22 forks source link

Back to original link when click report drill down #30

Closed widiramadhan closed 6 years ago

widiramadhan commented 6 years ago

how to call a report using drill down? I have a link http://172.22.0.28/ReportServer_GL_INSTANCE/Pages/ReportViewer.aspx?%2fBI%2fReport%2fNPF+Summary+(Drill+Down)&rs:Command=Render

when I call it is fine, but when the plus sign on the drill down is pushed back to the server link. how to handle it?

rb-cohen commented 6 years ago

There is a toggleItem method for opening/closing drill downs.

$report->toggleItem($toggleId);

The $toggleId is the ID of the element sent down in the report HTML, when you render the report you can use Javascript to listen for clicks on the toggle triggers, and then trigger an update with the clicked toggleId.

widiramadhan commented 6 years ago

i have code

$ssrs = new \SSRS\Report('172.22.0.28/ReportServer_GL_INSTANCE/', $options);
$result = $ssrs->loadReport('/BI/Collection/NPF/NPF Summary - 02. Area');
$ssrs->setSessionId($result->data['ExecutionID']);

$reportParameters = array(
'Area' => $area
);

$parameters = $ssrs->setExecutionParameters($reportParameters);

$output = $ssrs->render('HTML4.0'); // PDF | XML | CSV
echo $output;

where do i change it? I still do not really understand. please help me

widiramadhan commented 6 years ago

drill down pushed back to the server link picture1

image not show picture2

please help me

rb-cohen commented 6 years ago

Hi @widiramadhan,

I can't view the images, the URLs appear invalid, but given your code example, you would toggle (i.e. open/close) a dropdown like this:

$toggleId = $_GET['toggleId'];

$ssrs = new \SSRS\Report('172.22.0.28/ReportServer_GL_INSTANCE/', $options);
$result = $ssrs->loadReport('/BI/Collection/NPF/NPF Summary - 02. Area');
$ssrs->setSessionId($result->data['ExecutionID']);

$reportParameters = array(
'Area' => $area
);

$parameters = $ssrs->setExecutionParameters($reportParameters);

$ssrs->toggleItem($toggleId);

$output = $ssrs->render('HTML4.0'); // PDF | XML | CSV
echo $output;

To toggle an item in this example, you call your PHP script with a get parameter of the toggleId, so http://localhost/path/to/example.php?toggleId=efs55aasca

The toggle ID is a random ID sent down in the report by SSRS, you need to parse the HTML of the report to grab the toggleIds, or inject some javascript to reload the report with the toggleId parameter on click.

See https://docs.microsoft.com/en-us/sql/reporting-services/report-builder/rendering-to-html-report-builder-and-ssrs#show-and-hide for more info.

widiramadhan commented 6 years ago

Hi @rb-cohen, thanks for responding to my question.

I do not understand $toggleId obtained from where, because I just call the report simply by example. can you give me a reference?

I still can not find a way out, or can you help me step by step in making the report so that when the drilldown button is clicked it does not go to the original link and display the image from the report

image 1 image 2

rb-cohen commented 6 years ago

Hi @widiramadhan ,

The toggleId can be found in the generated report HTML. If you look at the HTML source code for the toggle buttons they will contain a unique ID in the <a href="" ....> tags.

Inject some Javascript in to the page displaying the report to listen for clicks on these elements, and re-render the report with the toggleId.

I don't have a working version of SSRS to set up a full working example but it will depend on your implementation. I'm afraid I'll be unable to help with the specifics of building of a report viewer.

Take a look at the source code of the report and hopefully it will make more sense.

widiramadhan commented 6 years ago

I find toggleId when inspect element -> http://myIp/ReportServer?%2FBI%2FCollection%20Monitoring%20(Drill%20Down)&rc%3ADataVisualizationFitSizing=Approximate&rc%3ASection=0&rs%3AFormat=HTML4.0&rs%3AShowHideToggle=159iT0R0x0

toggleId -> 159iT0R0x0

how do i call that toggle id into php?

rb-cohen commented 6 years ago

You'd call your PHP file with the toggleId as a parameter, one option would be as a GET parameter, so something like http://localhost/report.php?toggleId=159iT0R0x0

With the toggleId as a GET parameter you could then use the code in the example at https://github.com/ChartBlocks/php-ssrs/issues/30#issuecomment-369217174

widiramadhan commented 6 years ago

I did not call the report with the link <a href=" " .... > but I just display the report in a page like http://localhost/web/index.php?page=report-drilldown

code to call the report I have described above.

<div class = "box">
     I call this report based on the example that has been included ( https://github.com/ChartBlocks/php-ssrs/blob/master/samples/LoadReportWithParameters.php )
</ div>

therefore I am confused to put toggleId. can you tell me more clue?

if needed, this is my website look https://imgur.com/a/hMB5a

widiramadhan commented 6 years ago

Helo @rb-cohen ,

i try to hardcode parameter toggleId in address bar but not work. i try to get toggleId with $_GET['ShowHideToggle'] but ShowHideToggle not found. i try to hardcode toggleId in my code $ssrs->ToggleItem("159iT0R0x0"); but the message appears "The selected report is not ready for viewing. The report is still being rendered or a report snapshot is not available."

how to fix my issue?

rb-cohen commented 6 years ago

You could try some of these suggestions: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/e2813ac3-3322-456b-97c4-fd6545eedc6d/rsreportnotready?forum=sqlreportingservices

I think you'd get a different error if the toggleId no longer existed in the report, but worth checking that too.