This is from a project I worked on quite some time ago for a Developmental Programs Cognos project. Now with conditional blocks it can be other ways but this will demonstrate control over objects by code.
With conditional blocks display control is made easier but in situation where you want to have more control or just understand showing and hiding Cognos items in a report in more detail a simple Javascript can be used. The code can be modified easily enough for any situation.
1. Place the table
Starting with a blank report, we can use a basic table of three columns and three rows.
2. Place the permanent objects.
In the second row, place a chart in each table cell for a total of three charts.
3. Place the list reports.
In the third row add three list reports, one in each table cell. We'll call them ListReport1, ListReport2 and ListReport3.
4. Add HTML tags around list reports
In the first table cell, add an HTML item above ListReport1 and type in <div id="List1" style="display:none;">. Add an HTML item below the list report and type in </div>.
In the second table cell, add an HTML item above ListReport2 and type in <div id="List2" style="display:none;">. Add an HTML item below the list report and type in </div>.
And in the third table cell, add an HTML item above ListReport3 and type in <div id="List3" style="display:none;">. Add an HTML item below the list report and type in </div>.
You can save the report and run it now and it should show all three charts and no list reports. Items in the div tags are hidden.
5. Add radio controls
In the top row, middle table cell add an HTML item and insert the following Javascript or a modified version to suit what you need.
<Input type - radio Name=''r1" Value ="Show" onclick="javascript:Hide('List1','List2','List3')" checked><b>Hide Data</b>
<Input type - radio Name=''r1" Value ="Show" onclick="javascript:Show('List1','List2','List3')" checked><b>Show Data</b>
<script type="text/javascript">
function Hide(a,b,c) {
document.getElementById(a).style.display="none";
document.getElementById(b).style.display="none";
document.getElementById(c).style.display="none";
}
function Show(a,b,c) {
document.getElementById(a).style.display="block";
document.getElementById(b).style.display="block";
document.getElementById(c).style.display="block";
}
</script>
All that was done was some basic HTML and Javascripting to show and hide HTML DIV sections in order to allow a clean interface showing only charts when the report is run but the user can then view the data in the list reports as well if wanted.
Cognos Tips n Tricks
Wednesday, September 21, 2011
Introduction
I started programming long ago doing coding. I've coded Visual Basic .NET, PHP, ColdFusion, Javascript and other languages as well as some shell scripting. I was always a little partial to PHP and ColdFusion but in the end Cognos ended up being my career path. I rather like business intelligence as you can be technical but also creative. I mainly do metrics, scorecards, dashboards and reports. Mainly I use Report Studio, Metric Studio and Metric Designer.
This is just a blog that I started from my experience in Cognos and things that I've learned. I've found it to be much more complicated to develop metrics projects than reports and dashboards and, over time, I'll have some tips on both. For some reason there doesn't seem to be a lot of metrics developers in Cognos and that's where I've been working with over the years becoming on of the very, very few in my organization with in depth knowledge of metrics development.
Subscribe to:
Comments (Atom)