If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Expand Collapse Report in 10.2

Started by Deep750, 15 Mar 2013 05:33:32 AM

Previous topic - Next topic

Deep750

Hi,

IBM has made a script for expanding/collapsing columns, in e.g. list reports.

I can't get it to work in 10.2, when I run the report from the portlet (connection). The only thing displayed is the report header.

Has anyone made it function as it should in 10.2?
Can anyone please edit the script to work with 10.2?

PS. it works if I run the report from report studio.

http://www-01.ibm.com/support/docview.wss?uid=swg21377785

Deep750

XML for 10.1.1:
<report xmlns="http://developer.cognos.com/schemas/report/8.0/" expressionLocale="en-us" ignoreFilterContext="false"><!--RSU-SPC-0093 The report specification was upgraded from &quot;http://developer.cognos.com/schemas/report/4.0/&quot; to &quot;http://developer.cognos.com/schemas/report/8.0/&quot; at 2011-12-8. 15:55:43-->
<modelPath>/content/folder[@name='Samples']/folder[@name='Models']/package[@name='GO Sales (query)']/model[@name='model']</modelPath>
<queries>
<query name="Query1">
<source>
<model/>
</source>
<selection><dataItem aggregate="none" name="Country" rollupAggregate="none"><expression>[Sales (query)].[Branch].[Country]</expression></dataItem><dataItem aggregate="none" name="Product line" rollupAggregate="none"><expression>[Sales (query)].[Products].[Product line]</expression></dataItem><dataItem aggregate="none" name="Product type" rollupAggregate="none"><expression>[Sales (query)].[Products].[Product type]</expression></dataItem><dataItem aggregate="none" name="Product name" rollupAggregate="none"><expression>[Sales (query)].[Products].[Product]</expression></dataItem><dataItem aggregate="total" name="Quantity"><expression>[Sales (query)].[Sales].[Quantity]</expression></dataItem><dataItem aggregate="total" name="Gross profit"><expression>[Sales (query)].[Sales].[Gross profit]</expression></dataItem><dataItem aggregate="total" name="Revenue"><expression>[Sales (query)].[Sales].[Revenue]</expression></dataItem><dataItem aggregate="average" name="Unit price"><expression>[Sales (query)].[Sales].[Unit price]</expression></dataItem></selection>
<detailFilters><detailFilter postAutoAggregation="false" use="required"><filterExpression>[Country]='Australia' or [Country]='Brazil'</filterExpression></detailFilter></detailFilters></query>
</queries>
<layouts>
<layout>
<reportPages>
<page name="Page1"><style><defaultStyles><defaultStyle refStyle="pg"/></defaultStyles></style>
<pageBody><style><defaultStyles><defaultStyle refStyle="pb"/></defaultStyles></style>
<contents>
<list horizontalPagination="true" name="List1" refQuery="Query1" rowsPerPage="2000">
<style>
<defaultStyles>
<defaultStyle refStyle="ls"/>
</defaultStyles>
<CSS value="border-collapse:collapse"/>
</style>
<listColumns><listColumn><listColumnTitle><style><defaultStyles><defaultStyle refStyle="lt"/></defaultStyles></style><contents><textItem><dataSource><dataItemLabel refDataItem="Country"/></dataSource></textItem></contents></listColumnTitle><listColumnBody><style><defaultStyles><defaultStyle refStyle="lc"/></defaultStyles></style><contents/></listColumnBody></listColumn><listColumn><listColumnTitle><style><defaultStyles><defaultStyle refStyle="lt"/></defaultStyles></style><contents><textItem><dataSource><dataItemLabel refDataItem="Product line"/></dataSource></textItem></contents></listColumnTitle><listColumnBody><style><defaultStyles><defaultStyle refStyle="lc"/></defaultStyles></style><contents/></listColumnBody></listColumn><listColumn><listColumnTitle><style><defaultStyles><defaultStyle refStyle="lt"/></defaultStyles></style><contents><textItem><dataSource><dataItemLabel refDataItem="Product type"/></dataSource></textItem></contents></listColumnTitle><listColumnBody><style><defaultStyles><defaultStyle refStyle="lc"/></defaultStyles></style><contents/></listColumnBody></listColumn><listColumn><listColumnTitle><style><defaultStyles><defaultStyle refStyle="lt"/></defaultStyles></style><contents><textItem><dataSource><dataItemLabel refDataItem="Quantity"/></dataSource></textItem></contents></listColumnTitle><listColumnBody><style><defaultStyles><defaultStyle refStyle="lm"/></defaultStyles></style><contents/></listColumnBody></listColumn><listColumn><listColumnTitle><style><defaultStyles><defaultStyle refStyle="lt"/></defaultStyles></style><contents><textItem><dataSource><dataItemLabel refDataItem="Gross profit"/></dataSource></textItem></contents></listColumnTitle><listColumnBody><style><defaultStyles><defaultStyle refStyle="lm"/></defaultStyles></style><contents/></listColumnBody></listColumn><listColumn><listColumnTitle><style><defaultStyles><defaultStyle refStyle="lt"/></defaultStyles><CSS value="display:none"/></style><contents/></listColumnTitle><listColumnBody><style><defaultStyles><defaultStyle refStyle="lc"/></defaultStyles></style><contents><list horizontalPagination="true" name="List2" refQuery="Query1">
<style>
<CSS value="border-collapse:collapse"/>
<defaultStyles>
<defaultStyle refStyle="ls"/>
</defaultStyles>
</style>
<listColumns><listColumn><listColumnTitle><style><defaultStyles><defaultStyle refStyle="lt"/></defaultStyles></style><contents><textItem><dataSource><dataItemLabel refDataItem="Product name"/></dataSource></textItem></contents></listColumnTitle><listColumnBody><style><defaultStyles><defaultStyle refStyle="lc"/></defaultStyles></style><contents><textItem><dataSource><dataItemValue refDataItem="Product name"/></dataSource></textItem></contents></listColumnBody></listColumn><listColumn><listColumnTitle><style><defaultStyles><defaultStyle refStyle="lt"/></defaultStyles></style><contents><textItem><dataSource><dataItemLabel refDataItem="Unit price"/></dataSource></textItem></contents></listColumnTitle><listColumnBody><style><defaultStyles><defaultStyle refStyle="lm"/></defaultStyles></style><contents><textItem><dataSource><dataItemValue refDataItem="Unit price"/></dataSource></textItem></contents></listColumnBody></listColumn><listColumn><listColumnTitle><style><defaultStyles><defaultStyle refStyle="lt"/></defaultStyles></style><contents><textItem><dataSource><dataItemLabel refDataItem="Revenue"/></dataSource></textItem></contents></listColumnTitle><listColumnBody><style><defaultStyles><defaultStyle refStyle="lm"/></defaultStyles></style><contents><textItem><dataSource><dataItemValue refDataItem="Revenue"/></dataSource></textItem></contents></listColumnBody></listColumn><listColumn><listColumnTitle><style><defaultStyles><defaultStyle refStyle="lt"/></defaultStyles></style><contents><textItem><dataSource><dataItemLabel refDataItem="Quantity"/></dataSource></textItem></contents></listColumnTitle><listColumnBody><style><defaultStyles><defaultStyle refStyle="lm"/></defaultStyles></style><contents><textItem><dataSource><dataItemValue refDataItem="Quantity"/></dataSource></textItem></contents></listColumnBody></listColumn></listColumns></list></contents></listColumnBody></listColumn></listColumns><listPageHeader><listRows><listRow><rowCells><rowCell><contents><HTMLItem>
<dataSource>
<staticValue>&lt;span id="ExpandedTable"&gt; &lt;/span&gt;
&lt;script&gt;
var displayStyle = "";
var noDisplayStyle = "none";
var currentRow = 0;
var maxRowLength = 0;
var tbl;
//array with counts for each column to store how many minuses are in the column
var columnExpandCountArray;
//array of all columns, with values: 1-has icon, 2-always visible, 0-other
var columns;
function ExpandCollapse(el) {
var cid = el.parentNode.cellIndex;
// variable to know whether to change next columns
//  0-don't change; 1-show next columns, 2-hide next columns
var showNextColumns = 0;
if (isPlus(el)) {
el.src = "../pat/hal/images/minus.gif";
columnExpandCountArray[cid]++;
if (columnExpandCountArray[cid] == 1) {
showNextColumns = 1;
}
} else {
el.src = "../pat/hal/images/plus.gif";
columnExpandCountArray[cid]--;
if (columnExpandCountArray[cid] == 0) {
showNextColumns = 2;
}
}
var tr = el.parentNode.parentNode; // the current row
currentRow = tr.rowIndex;
showLines(el, cid);
hideOrShowColumns(cid, showNextColumns);
}
function showColumnVisibility(k, visible) {

for ( var i = 0; i &lt; tbl.rows.length; i++) {
var row = tbl.rows[i];
if (k &gt;= row.cells.length) {
continue;
}
// set the cell visibility
row.cells[k].style.display = visible ? displayStyle : noDisplayStyle;
}
}
function hideOrShowColumns(cid, showNextColumns) {
if (showNextColumns == 1) {
// must show the next columns
for ( var k = cid + 1; k &lt; maxRowLength; k++) {
if (columns[k] == 2) {
continue; // column is always visible
}
showColumnVisibility(k, true);
if (columns[k] == 1 &amp;&amp; columnExpandCountArray[k] == 0) {
return; // no need to go to the next columns
}
}
} else {
if (showNextColumns == 2) {
// must hide the next columns
for (k = cid + 1; k &lt; maxRowLength; k++) {
if (columns[k] == 2) {
continue; // column is always visible
}
showColumnVisibility(k, false);
}
}
}
}
function showLines(el, cind) {
var show = true; // to show lines or not
// Grab the ROW that was clicked and the TABLE that contains it
var tr = el.parentNode.parentNode; // the current row
var tbl = tr.parentNode.parentNode; // the table
if (isPlus(el)) {
show = false;
} else {
show = true;
}
while (currentRow &lt; tbl.rows.length - 1) {
currentRow++;
var row = tbl.rows[currentRow];
var iconIndex = getIconIndexInRow(row, 0);
if (iconIndex &gt;= 0 &amp;&amp; iconIndex &lt;= cind) {
row.style.display = displayStyle;
currentRow--;
return; // found the next line with icon in the same column; return
}
if (!show) {
row.style.display = noDisplayStyle;
} else {
row.style.display = displayStyle;
if (iconIndex &gt; cind) {
var icon = row.cells[iconIndex].firstChild;
showLines(icon, iconIndex);
}
}
}
}
function isPlus(el) {
return el.src.indexOf("minus") == -1;
}
function hasIcon(cell) {
// return true if this cell has an img
if ((Number(cell.childNodes.length)) == 0) {
return false;
}
var c = cell.firstChild;
if (c != null) {
return (c.tagName == "IMG");
}
return false;
}
function getIconIndexInRow(row, startId) {
for ( var i = startId; i &lt; row.cells.length; i++) {
if (hasIcon(row.cells[i])) {
return i;
}
}
return -1;
}
function showAll() {
for ( var i = 1; i &lt; tbl.rows.length; i++) {
row = tbl.rows[i]; // the current row
row.style.display = displayStyle; // show the row
}
}
function StartHidden() {
var q=document.getElementById("ExpandedTable");
// get the table
tbl = q.parentNode.parentNode.parentNode.parentNode;
for ( var i = 0; i &lt; tbl.rows.length; i++) {
var row = tbl.rows[i]; // the current row
if (row.cells.length &gt; maxRowLength) {
maxRowLength = row.cells.length;
}
}
columns = new Array(maxRowLength);
columnExpandCountArray = new Array(maxRowLength);
for ( var j = 0; j &lt; maxRowLength; j++) {
columns[j] = 0; // 0-default not icon, not always visible
}
var firstLineWithIcon = 0;
for (i = 1; i &lt; tbl.rows.length; i++) {
row = tbl.rows[i]; // the current row
if (hasIcon(row.cells[0])) {
// leave it visible, since it has + icon
if (firstLineWithIcon == 0) {
firstLineWithIcon = i;
}
} else {
row.style.display = noDisplayStyle; // hide the row
}
var index = getIconIndexInRow(row, 0);
if (index &gt; -1) {
columns[index] = 1; // 1- column has icon
}
}
for (j = 0; j &lt; maxRowLength; j++) {
columnExpandCountArray[j] = 0;
}
row = tbl.rows[firstLineWithIcon]; // the current row
for (j = 0; j &lt; row.cells.length; j++) {
if (columns[j] != 1 &amp;&amp; row.cells[j].childNodes.length &gt; 0) {
columns[j] = 2; // 2- always visible
}
}
for ( var k = 1; k &lt; maxRowLength; k++) {
if (columns[k] == 2) {
continue;
}
for ( var i1 = 0; i1 &lt; tbl.rows.length; i1++) {
if (k &gt;= tbl.rows[i1].cells.length) {
continue;
}
tbl.rows[i1].cells[k].style.display = noDisplayStyle; // hide the cell
}
}
}
&lt;/script&gt;</staticValue>
</dataSource>
</HTMLItem></contents><style><defaultStyles><defaultStyle refStyle="lh"/></defaultStyles></style></rowCell><rowCell><contents/><style><defaultStyles><defaultStyle refStyle="lh"/></defaultStyles></style></rowCell><rowCell><contents/><style><defaultStyles><defaultStyle refStyle="lh"/></defaultStyles></style></rowCell><rowCell><contents/><style><defaultStyles><defaultStyle refStyle="lh"/></defaultStyles></style></rowCell><rowCell><contents/><style><defaultStyles><defaultStyle refStyle="lh"/></defaultStyles></style></rowCell><rowCell><contents/><style><defaultStyles><defaultStyle refStyle="lh"/></defaultStyles><CSS value="display:none"/></style></rowCell></rowCells></listRow></listRows></listPageHeader><listPageFooter><listRows><listRow><rowCells><rowCell><contents><HTMLItem>
<dataSource>
<staticValue>&lt;script&gt;
StartHidden();
&lt;/script&gt;</staticValue>
</dataSource>
</HTMLItem></contents><style><defaultStyles><defaultStyle refStyle="lf"/></defaultStyles></style></rowCell><rowCell><contents/><style><defaultStyles><defaultStyle refStyle="lf"/></defaultStyles></style></rowCell><rowCell><contents/><style><defaultStyles><defaultStyle refStyle="lf"/></defaultStyles></style></rowCell><rowCell><contents/><style><defaultStyles><defaultStyle refStyle="lf"/></defaultStyles></style></rowCell><rowCell><contents/><style><defaultStyles><defaultStyle refStyle="lf"/></defaultStyles></style></rowCell><rowCell><contents/><style><defaultStyles><defaultStyle refStyle="lf"/></defaultStyles><CSS value="display:none"/></style></rowCell></rowCells></listRow></listRows></listPageFooter><listGroups><listGroup refDataItem="Country"><listHeader><listRows><listRow><rowCells><rowCell><contents><HTMLItem>
<dataSource>
<staticValue>&lt;img onclick='ExpandCollapse(this)' src='../pat/hal/images/plus.gif' style='cursor:hand;vertical-align:middle; margin-right:2px'/&gt;
&lt;span onclick='ExpandCollapse(this.previousSibling)' style='cursor:hand'&gt;</staticValue>
</dataSource>
</HTMLItem><textItem><dataSource><dataItemValue refDataItem="Country"/></dataSource></textItem><HTMLItem>
<dataSource>
<staticValue>&lt;/span&gt;
</staticValue>
</dataSource>
</HTMLItem></contents><style><defaultStyles><defaultStyle refStyle="oh"/></defaultStyles></style></rowCell><rowCell><contents/><style><defaultStyles><defaultStyle refStyle="oh"/></defaultStyles></style></rowCell><rowCell><contents/><style><defaultStyles><defaultStyle refStyle="oh"/></defaultStyles></style></rowCell><rowCell><contents><textItem><dataSource><dataItemValue refDataItem="Quantity"/></dataSource></textItem></contents><style><defaultStyles><defaultStyle refStyle="oh"/></defaultStyles></style></rowCell><rowCell><contents><textItem><dataSource><dataItemValue refDataItem="Gross profit"/></dataSource></textItem></contents><style><defaultStyles><defaultStyle refStyle="oh"/></defaultStyles></style></rowCell><rowCell><contents/><style><defaultStyles><defaultStyle refStyle="oh"/></defaultStyles><CSS value="background-color:white;display:none"/></style></rowCell></rowCells></listRow></listRows></listHeader></listGroup><listGroup refDataItem="Product line"><listHeader><listRows><listRow><rowCells><rowCell><contents/><style><defaultStyles><defaultStyle refStyle="ih"/></defaultStyles></style></rowCell><rowCell><contents><HTMLItem>
<dataSource>
<staticValue>&lt;img onclick='ExpandCollapse(this)' src='../pat/hal/images/plus.gif' style='cursor:hand;vertical-align:middle; margin-right:2px'/&gt;
&lt;span onclick='ExpandCollapse(this.previousSibling)' style='cursor:hand'&gt;</staticValue>
</dataSource>
</HTMLItem><textItem><dataSource><dataItemValue refDataItem="Product line"/></dataSource></textItem><HTMLItem>
<dataSource>
<staticValue>&lt;/span&gt;
</staticValue>
</dataSource>
</HTMLItem></contents><style><defaultStyles><defaultStyle refStyle="ih"/></defaultStyles></style></rowCell><rowCell><contents/><style><defaultStyles><defaultStyle refStyle="ih"/></defaultStyles></style></rowCell><rowCell><contents><textItem><dataSource><dataItemValue refDataItem="Quantity"/></dataSource></textItem></contents><style><defaultStyles><defaultStyle refStyle="ih"/></defaultStyles></style></rowCell><rowCell><contents><textItem><dataSource><dataItemValue refDataItem="Gross profit"/></dataSource></textItem></contents><style><defaultStyles><defaultStyle refStyle="ih"/></defaultStyles></style></rowCell><rowCell><contents/><style><defaultStyles><defaultStyle refStyle="ih"/></defaultStyles><CSS value="background-color:white;display:none"/></style></rowCell></rowCells></listRow></listRows></listHeader></listGroup><listGroup refDataItem="Product type"><listHeader><listRows><listRow><rowCells><rowCell><contents/><style><defaultStyles><defaultStyle refStyle="ih"/></defaultStyles></style></rowCell><rowCell><contents/><style><defaultStyles><defaultStyle refStyle="ih"/></defaultStyles></style></rowCell><rowCell><contents><HTMLItem>
<dataSource>
<staticValue>&lt;img onclick='ExpandCollapse(this)' src='../pat/hal/images/plus.gif' style='cursor:hand;vertical-align:middle; margin-right:2px'/&gt;
&lt;span onclick='ExpandCollapse(this.previousSibling)' style='cursor:hand'&gt;</staticValue>
</dataSource>
</HTMLItem><textItem><dataSource><dataItemValue refDataItem="Product type"/></dataSource></textItem><HTMLItem>
<dataSource>
<staticValue>&lt;/span&gt;
</staticValue>
</dataSource>
</HTMLItem></contents><style><defaultStyles><defaultStyle refStyle="ih"/></defaultStyles></style></rowCell><rowCell><contents><textItem><dataSource><dataItemValue refDataItem="Quantity"/></dataSource></textItem></contents><style><defaultStyles><defaultStyle refStyle="ih"/></defaultStyles></style></rowCell><rowCell><contents><textItem><dataSource><dataItemValue refDataItem="Gross profit"/></dataSource></textItem></contents><style><defaultStyles><defaultStyle refStyle="ih"/></defaultStyles></style></rowCell><rowCell><contents/><style><defaultStyles><defaultStyle refStyle="ih"/></defaultStyles><CSS value="background-color:white;display:none"/></style></rowCell></rowCells></listRow></listRows></listHeader></listGroup></listGroups></list>
</contents>
</pageBody>
<pageHeader>
<contents>
<block><style><defaultStyles><defaultStyle refStyle="ta"/></defaultStyles></style>
<contents>
<textItem><style><defaultStyles><defaultStyle refStyle="tt"/></defaultStyles></style>
<dataSource>
<staticValue/>
</dataSource>
</textItem>
</contents>
</block>
</contents>
<style>
<defaultStyles>
<defaultStyle refStyle="ph"/>
</defaultStyles>
<CSS value="padding-bottom:10px"/>
</style>
</pageHeader>
<pageFooter>
<contents>
<table>
<tableRows>
<tableRow>
<tableCells>
<tableCell>
<contents>
<date>
<style>
<dataFormat>
<dateFormat/>
</dataFormat>
</style>
</date>
</contents>
<style>
<CSS value="vertical-align:top;text-align:left;width:25%"/>
</style>
</tableCell>
<tableCell>
<contents>
<pageNumber/>
</contents>
<style>
<CSS value="vertical-align:top;text-align:center;width:50%"/>
</style>
</tableCell>
<tableCell>
<contents>
<time>
<style>
<dataFormat>
<timeFormat/>
</dataFormat>
</style>
</time>
</contents>
<style>
<CSS value="vertical-align:top;text-align:right;width:25%"/>
</style>
</tableCell>
</tableCells>
</tableRow>
</tableRows>
<style>
<defaultStyles>
<defaultStyle refStyle="tb"/>
</defaultStyles>
<CSS value="border-collapse:collapse;width:100%"/>
</style>
</table>
</contents>
<style>
<defaultStyles>
<defaultStyle refStyle="pf"/>
</defaultStyles>
<CSS value="padding-top:10px"/>
</style>
</pageFooter>
</page>
</reportPages>
</layout>
</layouts>
<classStyles>
<classStyle name="pd_1">
<CSS value="background-color:#009933; color:#FFFFFF;"/>
</classStyle>
<classStyle name="pd_2">
<CSS value="background-color:#FFFFFF; color:#009933;"/>
</classStyle>
<classStyle name="pd_3">
<CSS value="background-color:#FFFFFF; color:#CC9900;"/>
</classStyle>
<classStyle name="pd_4">
<CSS value="background-color:#FFFFFF; color:#990000;"/>
</classStyle>
<classStyle name="pd_5">
<CSS value="background-color:#990000; color:#FFFFFF;"/>
</classStyle>
</classStyles>
<XMLAttributes><XMLAttribute name="RS_CreateExtendedDataItems" output="no" value="true"/><XMLAttribute name="listSeparator" output="no" value=","/><XMLAttribute name="RS_modelModificationTime" value="2011-06-09T13:52:15.420Z" output="no"/></XMLAttributes><reportName>expandAndHide</reportName></report>