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

Twistie to remain open even after report runs.

Started by Web2CRM, 02 May 2013 09:27:37 AM

Previous topic - Next topic

Web2CRM

I need some help below Java Script.

I created a table with sets of Text Prompts and Value Prompts (Multi-Select) to be used by users to filter data.

When the report runs, the twistie "Advanced Search" hide the table with Text Prompts and Value Prompts.

When the user click the "Advanced Search" twistie, the table with Text Prompts and Value Prompts will show up and user will make a selection into these Prompts and once the user hit "Finish" button the report will display data based on the selection of the user.  The problem is - the twistie should remain open showing these Prompts even after the report runs.  Any help/suggestions is much appreciated.  Thanks in advance!!!!


<script language="JavaScript">
//<!--
var g_NavOpen = 0;

function toggleAdvancedSearchDiv(){
   if (g_NavOpen){
      document.getElementById('divPromptArea3').style.display="none";
      document.getElementById('anchorHideShow3').innerHTML="&#9658;";
      g_NavOpen = 0;}
   else{
      document.getElementById('divPromptArea3').style.display="";
      document.getElementById('anchorHideShow3').innerHTML="&#9660;";
      g_NavOpen = 1;}
}
//-->
</script>
<a href="javascript:toggleAdvancedSearchDiv()" border="0" style="font-size:10pt" style="text-decoration:none" style="font-weight:bold" id="anchorHideShow3">&#9658;</a>
<a href="javascript:toggleAdvancedSearchDiv()" border="0" style="font-size:10pt" style="font-family:arial" id="anchorHideShow3">Advanced Search</a>
<div id="divPromptArea3"  style="display:none">

sthabinash

You can do this by writing the if statement outside the function. i.e.

<script language="JavaScript">
//<!--
var g_NavOpen = 0;

if(g_NavOpen==0){
      document.getElementById('divPromptArea3').style.display="";
      document.getElementById('anchorHideShow3').innerHTML="&#9660;";
      g_NavOpen = 1;}

function toggleAdvancedSearchDiv(){
   if (g_NavOpen){
      document.getElementById('divPromptArea3').style.display="none";
      document.getElementById('anchorHideShow3').innerHTML="&#9658;";
      g_NavOpen = 0;}
   else{
      document.getElementById('divPromptArea3').style.display="";
      document.getElementById('anchorHideShow3').innerHTML="&#9660;";
      g_NavOpen = 1;}
}
//-->
</script>
<a href="javascript:toggleAdvancedSearchDiv()" border="0" style="font-size:10pt" style="text-decoration:none" style="font-weight:bold" id="anchorHideShow3">&#9658;[/url]
<a href="javascript:toggleAdvancedSearchDiv()" border="0" style="font-size:10pt" style="font-family:arial" id="anchorHideShow3">Advanced Search[/url]
<div id="divPromptArea3"  style="display:none">



Hope this helps

Web2CRM

Writing the if statement outside the function makes the twistie open when I initially ran the report; this should not be the case.  The twistie will only remain open after the initial run or when the user click that twistie for additional filter criteria. Also, I noticed that the twistie name in the report has [/url] ("Advanced Search[/url]") added in the report when I add the if statement outside the function.

sthabinash

Well you can do it if you can somehow manipulate the global variable 'g_NavOpen'.

Also you can do this by using a value prompt and manipulating it through JavaScript. I have attached the specification of the report with this post. You can use it and see if it is as you have desired. Here I have created a prompt with two static text and manipulated it through the JavaScript. I have just changed its selected index value to get the result. Though it may not be the best practice but it is the result that matters..... :P

Web2CRM

Hi sthabinash,

I am new to Cognos and I do not have much knowledge when it comes to Java Scripting, I am seeing that your approach would be the answer to my problem; however, I find it difficult to understand the attached file "Hide and Show.txt".  Appreciate if you can guide me atleast in detail steps on how to use the attached code, thanks again...

sthabinash

Quote from: Web2CRM on 03 May 2013 12:17:36 AM
Hi sthabinash,

I am new to Cognos and I do not have much knowledge when it comes to Java Scripting, I am seeing that your approach would be the answer to my problem; however, I find it difficult to understand the attached file "Hide and Show.txt".  Appreciate if you can guide me atleast in detail steps on how to use the attached code, thanks again...

Firstly, the attached file was the specification to a Cognos report where I tried to reciprocate the report you mentioned. You can open it by copying the content of the "Hide and Show.txt" and then opening a blank report of Report Studio and then going to the 'Tools' menu and clicking on 'Open Report from Clipboard'. The report may show error if your Cognos server does not have the same database 'Go Data Warehouse', but it doesnot matter as no data from the datasource are used. You can simply change the package to any other available package by clicking on 'Change Report Package' icon (contains two folder icon) available in Source window present at the left handside of the work area.


Now here are the steps that I used to create the report.

-I entered the below codes in a HTML item
Quote<a href="javascript:toggleAdvancedSearchDiv()" border="0" style="font-size:10pt" style="text-decoration:none" style="font-weight:bold" id="anchorHideShow3">&#9658;</a>
<a href="javascript:toggleAdvancedSearchDiv()" border="0" style="font-size:10pt" style="font-family:arial" id="anchorHideShow3">Advanced Search</a>
<div id="divPromptArea3"  style="display:none">

- The "Search Elements" is just an text Item which is then ended by the
Quote</div>
tag in an HTML tag. You can place your searching elements in place of "Search Elements" text Item.

- Then I added a blank value prompt i.e. I just gave a parameter name to the prompt and click finish for creating the prompt.
- Then I removed the header text of the value prompt by setting the 'Header Text' property of the prompt to 'Specified text' and left it blank.
- Then I added two static texts 'Hide' and 'Show' to the prompt. You don't need to use the same texts in the prompt as it doesn't really matter. What we really need is just two options in the value prompt for JavaScript to manipulate the report.

- Then, I named the value prompt 'pmpt' in the name option of value prompt properties.
- Set the visible option of the value prompt to 'No' if you do not want to display the prompt in the report. You could also set its size to 0 if you want.

- Then, I added the final script in the HTML tag. Remember, to keep this script after the value prompt or it may generate errors. I have referred to the prompt through javascript via 'getFormWarpRequest()._oLstChoicespmpt'. So, naming the value prompt is quite important. What I did in this script was I changed the selection of the value prompt each time I clicked the "Advanced Search" hyperlink. You could see the changes to value prompt by setting the visibility of the value prompt to YES while running the report.

Hope it helps.

Web2CRM

Hi sthabinash,

I can follow the steps except the last part, what is the final script in the HTML tag you are referring to? I am not sure the exact script contents in the Hide or Show.txt file that I need to copy.  If you can give me this final script then I think I'm all good.  Thanks!!!

Web2CRM

Hi sthabinash,

Your approach worked perfectly, thank you so much for your help.  ;)