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

how to conditionally execute javascript code

Started by mlodugu1, 25 Dec 2016 05:39:40 AM

Previous topic - Next topic

mlodugu1

Hi Gurus,

I would like to remove the top, page up, page down links at the bottom of cognos viewer based on a condition.
When the parameter count is 1 then I would like to remove the above links but when parameter count is greater than 1 then display the links as usual.

I am using the following javascript code in html item:
<style type="text/css">
.pageControls {
display: none;
}
</style>

I have tried Boolean as well as string variables that count the parameter  (paramcount(paramname(' ')) and return values based on which the html item should be executed by using the render variable option of the item as well as the html source variable but it just does not work.
Even tried block by placing html item inside and doing the above but it does not work.

The issue is I am using pagesets (cognos 10.2.1) as a result of which even for a single page output, the links page up page down appear activated and on clicking on page down a blank page appears. Would like to eliminate the blank page using the above method.

please suggest Solutions.


Regards
mlodugu1

SpareTire

#1
Hi,

Before considering javascript, have you considered why there is blank page to begin with? Have you considered using a render variable on your page set so that the final output does not have a blank page?

If you choose to go the J/S route, someone here has written it much more eloquently then I could: (http://stackoverflow.com/questions/29470249/how-to-count-selected-values-of-a-prompt-value-parameter-in-cognos)

You can use a hidden prompt to count the number of prompt values and then modify the J/S If function to display or not display the page controls.

UPDATE: Easier way---Insert the HTML into the footer of the report, use Source Type Report Expression. Use a report expressions such as:

If Paramcount('Parameter1')>0

Then


('<style type="text/css">
.pageControls {
display: none;
}
</style>')

ELSE

('<style type="text/css">
.pageControls {
;
}
</style>')

mlodugu1

Hi,

Thank you for the suggestions and info.

The issue I have is where we have used page sets to display different pages such as year, territory, product line, product type ( for ex) in separate pages. I have used render variables to display pages conditionally based on prompt choices. for example, 'paramdisplayvalue('year') is not null' has been used to render or not render the year page and so on for product line etc.

So inspite of using render variables, there is an etc blank page after the last page of output. The last but one page has the page down link activated. I have tried to use the above javascript code to hide the links (top page up page down bottom)'. It works when the user selects one parameter or all parameters but when the user selection is between 1 and maximum (I mean param count), there is still an etc blank page.

I think code to deactivate the 'page down' link on the last but one page is more appropriate. I could not find one so far. I am not a pro at JavaScript. Such a script or any other effective means to avoid the last blank page is what I need.


Regards,
mlodugu1

SpareTire

#3
Have you tried the following:
File>Report Properties>Page Break By Data Container For Interactive HTML > Set this to NO.
Then try Unchecking "always create extended data items
IBM has, as usual, a very cryptic note on this issue (http://www-01.ibm.com/support/docview.wss?uid=swg21341880).

I can't recreate  your problem so I am not sure exactly how your layout looks. Maybe give us a visual of your page structure?

As a last ditch effort--have you tried creating a manual page at the end of your page sets that uses the J/S above to remove the page up/page down buttons and just includes a button to return to prompt (or just says "last page").