javascript 在新窗口中打开 SSRS URL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18003013/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Open SSRS URL in New Window
提问by Keith Johnson
I have a report that passes an id that is used to access salesforce.com. I want to open SFDC as a new page from the URL hyperlink. However, nothing I do seems to be working!
我有一份报告传递了一个用于访问 salesforce.com 的 ID。我想从 URL 超链接打开 SFDC 作为新页面。但是,我所做的一切似乎都不起作用!
="javascript:void(window.open('https://na5.salesforce.com/&Fields!id.Value,'_blank'))"
="javascript:void(window.open(' https://na5.salesforce.com/&Fields!id.Value,'_blank'))"
Fields!id!Value is the SFDC id that is being passed. I'm trying this in the expression to no avail!
Fields!id!Value 是正在传递的 SFDC id。我在表达式中尝试此操作无济于事!
I know it is something VERY simple but I'm just not finding it. Thanks in advance for the assistance!
我知道这是非常简单的事情,但我只是没有找到它。预先感谢您的帮助!
UPDATE!!!
更新!!!
Figured it out!!! For the record, the syntax is:
弄清楚了!!!作为记录,语法是:
="javascript:void(window.open('https://na5.salesforce.com/" & Fields!id.Value & "'))"
="javascript:void(window.open(' https://na5.salesforce.com/" & Fields!id.Value & "'))"
回答by Christopher Brown
For the record, the problem with your original syntax was that you were trying to go from referencing an SSRS field to entering a string without separating the two properly. If you wanted your previous syntax to work (without removing the target window's name (i.e., '_blank'), you would do it like this:
作为记录,您原始语法的问题在于您试图从引用 SSRS 字段到输入字符串,而没有正确地将两者分开。如果您希望之前的语法起作用(不删除目标窗口的名称(即“_blank”),您可以这样做:
="javascript:void(window.open('https://na5.salesforce.com/" & Fields!id.Value & "','_blank'))"
I struggled with this for a long time, but you can make these pretty complex as long as you're careful to put everything together correctly. You can also add multiple javascript commands (but no functions) in the same action expression. Below is one of my most complicated SSRS Go-to-URL Action commands:
我为此苦苦挣扎了很长时间,但是只要您小心地将所有内容正确组合在一起,就可以使这些变得非常复杂。您还可以在同一个动作表达式中添加多个 javascript 命令(但不能添加函数)。下面是我最复杂的 SSRS Go-to-URL Action 命令之一:
="Javascript:"
& IIF(left(Fields!Name.Value,11)="RESTRICTED-",
"alert('Restricted!'); ","") & IIF(Fields!Name_Alert.Value = 1, "alert('Alternate Alert!'); ","")
& "void(window.open('"
& Globals!ReportServerUrl
& "/Pages/ReportViewer.aspx?%2fJPD%2fPO_Dashboard%2fJuvenile_Profile&rs:Command=Render"
& "&rc:Parameters=true"
& "&Emp_Number="
& Parameters!Param1.Value
& “&ID=" & Fields!ID.Value & "'));"
The key is to make sure that any and all necessary single quotes required by javascript show up inside a string (i.e., "'").
关键是要确保 javascript 所需的任何和所有必要的单引号都显示在字符串中(即“'”)。
回答by Stefan Steiger
Nonono, don't use ="javascript:void(window.open(
.
First, it breaks PDF & Excel reports,
and second, it doesn't work in IE11 and possible also < 11.
Tested it, worked only in Chrome for me.
And third, it's a mess to put it together.
诺诺,不要使用 ="javascript:void(window.open(
.
首先,它会破坏 PDF 和 Excel 报告,
其次,它在 IE11 中不起作用,也可能 < 11。经过
测试,仅在 Chrome 中对我有效。
第三,把它放在一起是一团糟。
There's a far easier & better solution:
Add &rc:LinkTarget=_blank
to your report access URL, like:
有一个更简单更好的解决方案:
添加&rc:LinkTarget=_blank
到您的报告访问 URL,例如:
https://your-domain.com/ReportServer/Pages/ReportViewer.aspx?%2fJPD%2fPO_Dashboard%2fJuvenile_Profile&rs:Command=Render&rc:LinkTarget=_blank
and it will open in a new windowtab.
它将以新的方式打开 窗户标签。
Edit:
If you want to make your own display page:
编辑:
如果要制作自己的显示页面:
This is how you get all reports:
这是您获取所有报告的方式:
USE [ReportServer$MSSQL_2008_R2]
SELECT
[ItemID]
,[Path]
,[Name]
,[ParentID]
FROM [Catalog]
WHERE Type = 2
And this is how you can display all folders/reports at level x
这就是您如何在 x 级显示所有文件夹/报告
;WITH CTE AS
(
SELECT
[ItemID]
,[Path]
,[Name]
,[ParentID]
,0 AS lvl
,CAST([Name] AS nvarchar(MAX)) AS RecursivePath
FROM [Catalog]
WHERE [ParentID] IS NULL
UNION ALL
SELECT
[Catalog].[ItemID]
,[Catalog].[Path]
,[Catalog].[Name]
,[Catalog].[ParentID]
,cte.lvl +1 AS lvl
,CAST(cte.RecursivePath + '/' + [Catalog].[Name] AS nvarchar(MAX)) AS RecursivePath
FROM CTE
INNER JOIN [Catalog]
ON [Catalog].ParentID = CTE.ItemID
)
SELECT * FROM CTE
WHERE lvl = 1
ORDER BY lvl, Path
If you only want the folders:
如果您只想要文件夹:
WHERE Type = 1
If you only want the data-sources:
如果您只想要数据源:
WHERE Type = 5
回答by Danny Cullen
If you are wanting to link to an external URL and want the links to work both within the report viewer and if you export to Excel for example, I use the following expression.
例如,如果您想要链接到外部 URL 并希望链接在报表查看器中工作以及导出到 Excel,我将使用以下表达式。
=IIF(
Globals!RenderFormat.Name = "RPL",
"javascript:void(window.open('http://www.domain.com/page/" & Fields!Page_ID.Value & "','_blank'))",
"http://www.domain.com/page/" & Fields!Page_ID.Value
)
It will use the JavaScript if viewing from within the report in the browser and standard linking otherwise.
如果从浏览器中的报告中查看,它将使用 JavaScript,否则将使用标准链接。