我有一个使用CrystalReportViewer设置 ASP.NET 站点。当用户打开报表时,将显示参数提示。如果他们遇到报告问题,则参数提示中没有关闭选项,它似乎逃脱的唯一方法是使用浏览器的后退按钮退出。
这对我们不起作用,因为出于其他原因,本网站上的用户已被指示不要使用后退按钮(此说明超出了我的控制范围。由于参数提示会阻止页面上的任何其他链接,因此用户无法单击退出。如何打开提示的关闭按钮?
如果有人仍然需要解决方案,这是我之前在SAP论坛上写的另一个解决方案,它要简单得多,并且不会向页面注入任何内容。关闭按钮实际上已经存在,他们只是隐藏了它。
http://scn.sap.com/message/14895166#14895166
从 $(document(.ready 调用此函数。它将自动 每 1/3 秒触发一次自身,直到参数框的关闭 按钮设置为可见。在那之后,它将停止 运行。我通过使用"检查对象"找到了这个div 及其类 浏览器的功能。
祝你好运。
window.$my = {
dlgCloseBtn: $('div.dlgCloseBtn')
};
$(document).ready(function() {
enableDlgCloseBtn();
});
/*
** Loops every third of a second until the parameter box's Close button can be made visible.
*/
function enableDlgCloseBtn() {
if ($my.dlgCloseBtn.css('visibility') === undefined) {
$my.dlgCloseBtn = $('div.dlgCloseBtn');
} else if ($my.dlgCloseBtn.css('visibility') !== 'visible') {
$my.dlgCloseBtn.css('visibility', 'visible');
return;
}
window.setTimeout(enableDlgCloseBtn, 333);
}
好的,似乎此功能在 Web 的 Crystal 报表查看器中不存在。为了解决这个问题,我为我的页面编写了一些Javascript,在参数提示符中注入了一个自制的"退出"按钮:
// Forces an exit button into the parameter prompt
function addExitButton() {
// "ReportViewer" is the name of my CRV, replace with yours
// Also, you will probably need to adjust the path to the button image URLs
var okButton = document.getElementById('ReportViewer_submitButton');
if (okButton != null) {
var exitLink = '<<URL you want the Exit button to link to here>>';
var row = okButton.parentNode.parentNode.parentNode;
if (row != null) {
var spacer = document.createElement("td");
spacer.innerHTML = ' ';
row.appendChild(spacer);
var startCell = document.createElement("td");
startCell.innerHTML = '<img src="../crystalreportviewers13/prompting/images/button_left_normal.gif" />';
row.appendChild(startCell);
var cell = document.createElement("td");
cell.setAttribute("class", "pePromptButton");
cell.setAttribute("background", "../crystalreportviewers13/prompting/images/button_middle_normal.gif");
cell.innerHTML = '<div class="pePromptButton"><a href="' + exitLink + '" title="Exit"> Exit </a></div>';
row.appendChild(cell);
var endCell = document.createElement("td");
endCell.innerHTML = '<img src="../crystalreportviewers13/prompting/images/button_right_normal.gif" />';
row.appendChild(endCell);
}
}
else
setTimeout(addExitButton, 10);
}
addExitButton();
这已经过测试,似乎工作正常。