Printing Reporting Services in a page throught Javascript
I Have a PerformancePoint Server 2007 Dashboard in a Sharepoint 2007 page.
In my Sharepoint page, there's 2 Filters who get passed to the Report, and I need to print this report in the page (in another button, not the SSRS one).
So what I need is a javascript method that calls the SSRS print button, which is on a named DIV, inside a WebPartZone that only have one WebPart, a PerformancePoint Dashboard Item (don't know the exact name of the webpart).
Edit: I've noticed that the Report, that is sh开发者_开发问答own by an PerformancePoint Server webpart, is being shown by an IFrame in my Sharepoint Page.
Edit2: Due to my architecture the reporting services Iframe is on another server, causing Access Denied when accessing through javascript. So the question in the way I wanted is not answerable anymore, however I'll try to answer the question directly inside the reporting services, just to keep the question answer accurate.
The onclick event for the print button is document.getElementById('ReportViewerControl').ClientController.LoadPrintControl();return false;
, however I was unsuccessful in just adding that to another link outside of the report viewer. That makes sense, since you can have multiple reports on a page and there's one print button for each.
Maybe you can try forcing a click of the print button?
document.getElementById('ReportViewerControl_ctl01_ctl07_ctl00_ctl00').onclick();
in my document, anyway.
Solved it: Since the SSRS was inside an Iframe of my Sharepoint i had to look inside the Iframe (this only works when the Iframe access the same server of the webpage currently accessed or else we will get a access denied in javascript and fail silently) I used JQuery to make things simpler and used IE 8 to lookup the nodes (since PerformancePoint Server 2007 doesn't appear in Firefox)
Nathan's javascript helped me alot, I've checked the button html structure and find that it's a table that handle's the click and the table has a attribute called title with a value called Print (note the uppercase on the firt letter), so I written this little JQuery Javascript to solve this.
$('iframe').contents().find('table[title="Print"]').click();
remembering that this won't help me, because in my case the SSRS is hosted on another server, and therefore it's not accessible throught javascript, I've just completed the answer to help other people in this situation.
精彩评论