COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: everlearner on 20 Jun 2014 06:17:43 AM

Title: is it possible hide/unhide a block by java script?
Post by: everlearner on 20 Jun 2014 06:17:43 AM
Hi Gurus,

i have a block with some content on my prompt page,
the requirement is the block should be hide by default, when user click a hyperlink then it has to display. again when clicked hyperlink has to hide.

is it possible by java script,
any one have idea about this???

thanks in adv


Title: Re: is it possible hide/unhide a block by java script?
Post by: Raghuvir on 20 Jun 2014 07:00:25 AM
not the right person to comment on javascript, but can u try to achieve your requirement by using conditional block ?

Regards
Title: Re: is it possible hide/unhide a block by java script?
Post by: BigChris on 20 Jun 2014 07:49:15 AM
as Raghuvir says, you should be able to do this with a conditional block / render variable based on an auto submitting prompt.
Title: Re: is it possible hide/unhide a block by java script?
Post by: MDXpressor on 20 Jun 2014 09:11:01 AM
Quote from: BigChris on 20 Jun 2014 07:49:15 AM
as Raghuvir says, you should be able to do this with a conditional block / render variable based on an auto submitting prompt.

Yes a conditional block will work.  This is a server-side action however, and that will cause the report to reload the data.  For a quick report this is not an issue, for a report that takes 5 minutes to load, it might be...

Quote from: Raghuvir on 20 Jun 2014 07:00:25 AM
not the right person to comment on javascript, but can u try to achieve your requirement by using conditional block ?

Regards

Further proof that .js itself is not the risk. But the pool of resources who know Cognos is small.  The pool of resources who know Cognos AND .js is very very small.  Make sure you know what you're committing your company to when you introduce .js.  If you don't know how to hide a simple <div>, then my concern is that you are over your head where .js is concerned.  So, if you're simply trying to learn and expand your horizons, I applaud you.  If you are trying to add bling to your report, I'd suggest sticking with traditional Cognos solutions (conditional blocks).

... my 2 cents.
Title: Re: is it possible hide/unhide a block by java script?
Post by: everlearner on 23 Jun 2014 01:34:01 AM
i done it by conditional block, also simply trying to learn the same by java script.
thanks all for ur replies.
Title: Re: is it possible hide/unhide a block by java script?
Post by: rprameshwor on 23 Jun 2014 04:43:50 AM
yes, it is possible to get done through javascript.

enclose your block with a div tag , lets say 'prompt'
Put a button outside the div which on clicking calls a function, lets say toggle
A rough JS logic given below :

button : <input type='button' onClick='toggle()' value='show-hide prompts'>

<script>
function toggle{
if(document.getElementById('prompt').style.display=='none')
document.getElementById('prompt').style.display='block';
else
document.getElementById('prompt').style.display='none';
}
</script>