简体   繁体   English

是否可以将 javascript 嵌入到 SSRS 报告中?

[英]Is it possible to embed javascript into an SSRS Report?

SQL Server reports can embed vbscript and execute client side, but can the same be done with javascript? SQL Server 报表可以嵌入 vbscript 并执行客户端,但可以用 javascript 来完成吗? I think there would be great utility to be able to execute jQuery and CSS manipulation client side to create a more interactive drill down experience.我认为能够执行 jQuery 和 CSS 操作客户端以创建更具交互性的向下钻取体验会有很大的效用。

Are we talking about SQL Server Reporting Services?我们在谈论 SQL Server Reporting Services 吗?

If so, I have not ever seen a method to do it.如果是这样,我还没有见过这样做的方法。 I will admit that the notion makes my skin crawl, though.不过,我承认这个想法让我的皮肤爬行。

Edit编辑

Here is a small example of using JavaScript to open a separate window in a hyperlink.这是一个使用 JavaScript 在超链接中打开单独窗口的小示例

This blog article may contain even better information for some interesting JavaScript techniques in reporting services.这篇博客文章可能包含有关报告服务中一些有趣的 JavaScript 技术的更好信息。

It sounds to me like Reporting Services is the wrong front end for your job.在我看来,Reporting Services 是您工作的错误前端。 The RDL (report definition) files are basically XML. RDL(报告定义)文件基本上是 XML。 I don't know of a way to add code to XML.我不知道将代码添加到 XML 的方法。

If you consider the RDL output to be your "data" then it doesn't really make sense to house any behavior here any way.如果您认为 RDL 输出是您的“数据”,那么以任何方式在此处容纳任何行为都没有任何意义。 Instead, you may want to build a front end which can consume the final report output then provide the experience you are looking for.相反,您可能希望构建一个前端,该前端可以使用最终报告输出,然后提供您正在寻找的体验。

I know this is an old post however something like this works fine我知道这是一个旧帖子,但是像这样的东西很好用

="javascript:void(window.open('https://" + Parameters!ServerName.Value + "/ReportServer/Pages/ReportViewer.aspx?%2f" + Parameters!Environment.Value + "%2fSSRS+Reports%2fReports%2fVE%2fMy+Reports%2fData+View%2fReport+Name%2f60-Your-Report&rs:Command=Render','_blank'))" ="javascript:void(window.open('https://" + Parameters!ServerName.Value + "/ReportServer/Pages/ReportViewer.aspx?%2f" + Parameters!Environment.Value + "%2fSSRS+Reports%2fReports %2fVE%2fMy+Reports%2fData+View%2fReport+Name%2f60-Your-Report&rs:Command=Render','_blank'))"

I have an important note to add about this post, if you try to test the javascript in your SSRS report using PREVIEW in Visual Studio (BIDS), it will NOT run in preview mode, but after you deploy the report to an actual report server, then the javascript will work when viewing the report in the web browser.关于这篇文章,我有一个重要的说明要添加,如果您尝试使用 Visual Studio (BIDS) 中的 PREVIEW 测试 SSRS 报告中的 javascript,它将不会在预览模式下运行,但是在您将报告部署到实际报告服务器之后,然后在 Web 浏览器中查看报告时 javascript 将起作用。 This caused me a lot of confusion I hope to save some others the trouble.这给我带来了很多困惑,我希望能省去其他人的麻烦。

Here is a specific example when and why I frequently use javascript in SSRS.这是我在 SSRS 中经常使用 javascript 的时间和原因的具体示例。 On SSRS reports, it is nice to have hyperlinks to web services or other applications outside of SSRS.在 SSRS 报告中,最好有指向 SSRS 之外的 Web 服务或其他应用程序的超链接。 In the example below, a "link" field is created in SQL and used in the SSRS report to create a hyperlink to MS Dynamics CRM to a specific Opportunity of a specific Lead.在下面的示例中,在 SQL 中创建了一个“链接”字段,并在 SSRS 报告中使用它来创建指向 MS Dynamics CRM 的超链接,指向特定潜在客户的特定商机。

First, create the http link field with something like this ... ignore the case statement if you do not need to have a different link for different environments.首先,使用类似这样的内容创建 http 链接字段...如果您不需要为不同的环境使用不同的链接,请忽略 case 语句。

   ,case
        when @@SERVERNAME like '%CF-PROD%' then 'http://cf-prod-crm01:5559/crm.ashx?id=' + CAST(c.OpportunityID as varchar(36))
        when @@SERVERNAME like '%CF-STG%' then 'http://cf-stg-crm01:5559/crm.ashx?id=' + CAST(c.OpportunityID as varchar(36))
        when @@SERVERNAME like '%CF-QA%' then 'http://cf-qa-crm01:5559/crm.ashx?id=' + CAST(c.OpportunityID as varchar(36))
        when @@SERVERNAME like '%CF-DEV%' then 'http://cf-dev-crm01:5559/crm.ashx?id=' + CAST(c.OpportunityID as varchar(36))
        END AS 'CRMOpportunityLink'

To test, this link should work if you were to copy it and put it manually into a browser for your specific app.为了测试,如果您要复制它并手动将其放入特定应用程序的浏览器中,此链接应该可以工作。

In a report, such as SSRS, you can create a hyperlink using Javascript in the Action area in TextBox, select "Go to URL" and insert the following:在报告中,例如 SSRS,您可以在 TextBox 的操作区域中使用 Javascript 创建超链接,选择“转到 URL”并插入以下内容:

"javascript:void(window.open('" + Fields!CRMOpportunityLink.Value + "','_blank'))")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM