因此,您应该使用getElementsByTagName方法,而不是getElementById。示例如下:
Ironside-IBM Cognos和JavaScript-第二部分
另一个可以简化工作的技巧是在Cognos中使用jQuery。这里有很好的记录:
Cognos中使用jQuery的动态报告
我在这里写了一个例子:
Cognos中使用jQuery的动态自定义异常
关于使用javascript的其他Cognos文档可以在这里找到:
Cognos-升级JavaScript应用程序
这在一个cognos列表中。所以我知道很多JS,但显然不足以理解这一点。我有一个列表,在这个列表中,我有一种层次结构,它将在中展开几个层。我希望除了第一层之外,所有层都开始隐藏。所以像这个
第一层(显示)第二层(隐藏)第三层(隐藏)
我的JS代码在下面,我一辈子都搞不清楚。如有任何帮助,我们将不胜感激。
function StartHidden() {
var q=document.getElementById("ExpandedTable");
// get the table
tbl = q.parentNode.parentNode.parentNode.parentNode;
var isFirstRow=true;
for ( var i = 0; i < tbl.rows.length; i++) {
var trCurrent = tbl.rows; // the current row
var d = trCurrent.cells[0]; // first cell
var c = d.firstChild;
if (i < 2 || c.tagName.indexOf("IMG") != -1) {
c = c.src; // leave it visible, since it has + icon
for ( var j = 1; j < trCurrent.cells.length; j++) {
trCurrent.cells[j].width="1";
}
}
else {
trCurrent.style.display = "none"; // hide the row
}
}
}
为了在报表中处理Cognos Javascript对象,您必须使用getFormWarpRequest函数,而不是直接处理文档对象
正确的代码片段应该是:
var fW = (typeof getFormWarpRequest == "function" ?getFormWarpRequest() : document.forms["formWarpRequest"]);
// if it’s undefined, check if it is running in a portlet
if ( !fW || fW == undefined) { fW = ( formWarpRequest_THIS_ ?formWarpRequest_THIS_ : formWarpRequest_NS_ );}
然而,这只是解决方案的一部分,因为在Cognos8.4中,数据对象(列表、交叉表)是用动态名称和IDS生成的因此,您应该使用getElementsByTagName方法,而不是getElementById。示例如下:
Ironside-IBM Cognos和JavaScript-第二部分
另一个可以简化工作的技巧是在Cognos中使用jQuery。这里有很好的记录:
Cognos中使用jQuery的动态报告
我在这里写了一个例子:
Cognos中使用jQuery的动态自定义异常
关于使用javascript的其他Cognos文档可以在这里找到:
Cognos-升级JavaScript应用程序