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

Dropdown Check box

Started by babu babu, 03 Dec 2010 07:21:47 PM

Previous topic - Next topic

babu babu

Hi,
How can i get dropdown check list in value prompt when i am using multi select option(like gmail labels option).Please let me know.

Thanks!
Anand.

PRIT AMRIT

Have you got a work around for this requirement.

I have a similar requirement. I have a value prompt with multi select. Instead of a 'List Box/Check Box Group' I want the drop down with multiple selection option.

Is it possible?

Thanks
Prit

Sunchaser

Hi all,

Technically and directly from Cognos, I don't know if it is feasible but I would tend to say that it is a kind of "nonsense" (please don't take it against you).
In the "programmatic" point of view, how is it possible to say to the object that the selection is done -> means the user has finished to tick the checkboxes (and he is not only hesitating between two choices for example) and then the object can close the drop-down list ?
Basically with a drop-down list, the user click on an arrow, make one selection in the list, then the drop-down is closed and the value of a variable / parameter (or whatever behind) is updated, and eventually - if existing - a function is called / triggered, etc ...
I'm repeating myself but, I'm really wondering how it could be then possible to indicate to the object that the selections are done; I don't think it would be a "natural" behaviour, even for a user, as most of the time they are used to deal with simple things.

Regards
Vinc.

PRIT AMRIT

Hi Vinc,

Very true and I do agree with you 100% and the same questions came to mind as well. I am just coming from the meeting with Users and convinced them the difficulties would be caused from such functionalities.

We agreed to stick to the simple multi select with List Box option.

Thanks for your valuable suggestions.

Cheers

Prit


Amruta Gandhi

#4
   Although this functionality cannot be achieved directly by Cognos, it can be implemented with the help of JavaScript. If usage of JavaScript is allowed, then following implementation can be used to give the look of a single select prompt to a multiselect prompt.  The Multiselect Prompt here is of List Box type.
   When the user clicks on the drop down of the single select prompt shown in the report, then the corresponding multiselect prompt is seen. After selecting the various parameters from the multiselect prompt it is hidden on the click of any place in the document outside the multiselect prompt.
For example let's create a multi select prompt for selection of Product Line. Paste the following scripts in the positions mentioned as below:
1.   Place the following script in an HTML item Before the Prompt:
<SELECT name="reportDropDownPL" onclick="javascript:changePromptType(this);" readonly style="FONT-SIZE: 10pt; WIDTH: 140px; FONT-FAMILY: 'Arial';display:block">
    <OPTION VALUE="1" SELECTED >Product Line</OPTION>
/*
Note: The term before the 'DropDownPL' (of SELECT tag as above) and 'PromptPL' (Div id of multiselect prompt as below) should be same. In this case it is 'report'.
The SELECT tag here is used to make a single select prompt showing Product Line, with the help of javascript instead of the default cognos value prompt.
This will help save more space in the report.
*/

</SELECT>
<div id="reportPromptPL" style="margin:0px;padding:0px;display:none;position:absolute">

Please Note: For the single select prompt and multiselect prompt to look similar, both should be of the same width. Here, the width in SELECT tag of the above script (which acts as Single select prompt) is 140 px. Hence, define the width of the multiselect prompt as 140 px through the size and overflow option of the prompt. Also, take care to hide the adornments of multiselect prompt. Depending on the requirement, set the Required property of the prompt to 'Yes' or 'No'. It is desirable to provide the default selection to the prompt.

2.   Place the end tag for div in an HTML item After the prompt </div> 

3.   Place an HTML item at the starting i.e. before the HTML item of the starting of the Prompt and paste the script as below in it. Here, the function showHideMultiSelectPrompt along with function changePromptType is used to give a look of combo box for the prompts. It typically displays and hides the multiselect prompt on the click of single select prompt seen in the report.
<script>
var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);
if ( !fW || fW == undefined) { fW = ( formWarpRequest_THIS_ ? formWarpRequest_THIS_ : formWarpRequest_NS_ );}

var expPromptDivName ="PL";
var expPromptName = "reportPromptPL"; //assign the div id of the multiselect prompt of report to this expPromptName variable. Here it is reportPromptPL.


// function for displaying multiselect drop down prompt --------------------------------------

function showHideMultiSelectPrompt(){
   var clickObj = event.srcElement;   
   if(clickObj && clickObj.name && clickObj.name.match('[a-z]+DropDown'+expPromptDivName )){
      var promptName = clickObj.name.match(/([a-z]+)DropDown([A-Z]{2})/)[1];
      var multiSelectPrompt = document.getElementById(promptName+'Prompt'+expPromptDivName);
      if(multiSelectPrompt.id == expPromptName){
         multiSelectPrompt.style.display = multiSelectPrompt.style.display=="none"?"block":"none";
      }else{
         multiSelectPrompt.style.display = "block";
         document.getElementById(expPromptName).style.display = "none";
         expPromptName = multiSelectPrompt.id;
      }
   }else if(clickObj && clickObj.type != 'select-multiple')
      document.getElementById(expPromptName).style.display = "none";
}

function changePromptType(oPrompt){
   if(oPrompt.multiple == false){
      oPrompt.multiple = true;
      oPrompt.multiple = false;
   }
}

document.onclick=showHideMultiSelectPrompt; //function called to hide the multiselect prompt, when clicked anywhere on the page.
</script>

4.   The above implementation does not hide the default Cognos option of 'Select all Deselect all' seen below the multiselect prompt. It is recommended to hide these options to give a better look and feel of the implementation. To hide these options you may use the following CSS script. Paste the below script in an HTML Item placed on the report.
<STYLE Type="Text/CSS">
DIV.clsPromptComponent DIV A{
   display:none;
}
</STYLE>

Please let me know if anything else is needed or the solution was helpful.


                                                     

PRIT AMRIT

hi Amruta,

A pretty smart work around . I have tried to do a sample as per the steps provided by you. It works fine.

Since I don't have much JS knowledge, Instead of 'List box', can we make it 'Check box group'?

Thanks
Prit

Amruta Gandhi

Thanks Prit,

The above script can be used for a checkbox type prompt too. Just try changing the UI of the Prompt from ListBox to CheckBox. You may require to set the width of the prompt accordingly (both the Cognos Checkbox prompt and the width as mentioned in the SELECT tag).  Please let me know if you face any issues.


PRIT AMRIT

Hi Amrutha,

I had tried so and it's working also fine but the problem is the moment I select one value from 'Multi Select' check box, it closes and doesn't allow me to do multi select at a time. So I have to click several time in order to make multi selection.

Any clue?

Thanks


Sunchaser

Hi all,

I would tend to say that the main problem is that when you click on a checkbox, you "activate" the onclick event of the document, which is at a higher level than the checkbox prompt.
Then it will be necessary to override the onclick event of this object in order to avoid the event to be seen at document level.
In the same time, a "setTimeOut" (or equivalent) event could be put after each click on the checkbox in order to hide the object only - for example - one second after the click, in order to let to the user the possibility to do an other selection.

Amruta Gandhi

Hi Prit,
The problem is due to the document.onclick which calls the function when we click anywhere outside the prompt as rightly suggested by Sunchaser. So, to overcome this we can have an option where in, the Prompt would open and hide on the click of the single select prompt seen on the report. Not much to be done for that, just remove the line "document.onclick=showHideMultiSelectPrompt; " from the script.
Add the statement "showHideMultiSelectPrompt();"   in the changePromptType function as shown below:

function changePromptType(oPrompt){
   if(oPrompt.multiple == false){
      oPrompt.multiple = true;
      oPrompt.multiple = false;
   }
showHideMultiSelectPrompt();
}


This would show the multiselect prompt on the click of the single select prompt and hide it only when it is clicked on that prompt again. However, it would not Hide the multiselect prompt when it is clicked anywhere on the screen.
Please let me know if I was able to solve your query.

kiran04

Hi Amrutha,
I had a similar kind of issue where i have two promptsi.e, the first is a dropdown list and second is check box .
The drop down has 4 values and check box has 1 value. Here the condition is I have to display the checkbox for only 1 value of the dropdown list and for the others it should not display. So,
what I have done is I took a conditional variable and used conditional block for that check box prompt. It is working fine but the issue is as it was a cascaded prompt ,.. i used autosubmit is equal to on..so for that ..the other conditions where i should not display the checkbox..there the report is running without hitting the run button..
I got a solution for this to keep a reprompt button in between the checkbox and run button .
but the user requirement doesn't permit me to do that..
so is there any way the java script can help me??

Amruta Gandhi

Hello KWASO4,
Replicating your requirement I created a report with a single select value prompt for "Product Line", check box prompt for "Year", a "FINISH" button and a "List". The checkbox for year is pointed to Year query and contains only one value of 2005, in line to your requirement. This checkbox would be seen only when the Product Line "Mountaineering Equipment" is selected in the Product Line prompt.
For the Product Line prompt two conditions are to be noted:
1.   Auto Submit is made off
2.   Name of the Product Line prompt is specified as ProductLine. This name is used in the script hence needs to be followed. In case this is changed, the corresponding place where it is used, also should be changed accordingly (Similar comments are added in the place where it is used).
A FINISH button is added to apply the Prompt selections.
There is a list which contains Product Line, Year and Revenue. When any other Product Line except Mountaineering Equipment is selected, the list shows data for all the years for corresponding Product Line. When "Mountaineering Equipment" is selected AND "2005" is checked, then list filters for both the selections, else it filters for only Product Line. In the list query, the following filter condition is added besides the Product Line filter ([Product line code]=?PL?):
if (?PL?=992)
then ([Year]=?Prod?)
else (1=1)

This filter is made optional as it has to be applied only when the Year prompt is checked. Here, in the If condition (i.e. at the place of 992) specify the ID/Value of the selection for which the checkbox filter has to be applied.
Following are the places specified where script needs to be added in HTML Tags:
1. Before the Value Prompt of Product Line add the following script:
<script>
var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);
if ( !fW || fW == undefined) { fW = ( formWarpRequest_THIS_ ? formWarpRequest_THIS_ : formWarpRequest_NS_ );}


function HideShowPrompt()
{
   var objDiv= document.getElementById("parentPrompt");
   var objOptions = objDiv.getElementsByTagName("OPTION");
//In the following script a loop is driven to check each selection of prompt and match it with desired value. When the desired value is met the checkbox prompt would be seen, else it would be hidden.
   for (i=0;i<objOptions.length;i++)
   {
      if (objOptions.selected == true)
      {
         if(objOptions.innerText== "Mountaineering Equipment") //specify the name of the selection, for which you need to show the checkbox prompt. Here it is Mountaineering Equipment.
         {
            document.getElementById("childPrompt").style.display="block";

         }
         else
         {
            document.getElementById("childPrompt").style.display="none";

         }
      }
   }
}
</script>
<div id="parentPrompt" >

2. After the Product Line Prompt add
</div>
3. Before the checkbox prompt add:
<div id="childPrompt" style="display:none">
4. After the checkbox prompt add:
</div>

<script>

fW._oLstChoicesProductLine.onchange= function (){HideShowPrompt();}
/*Here, the function HideShowPrompt is called when the selection of the Parent Prompt is changed.
Please Note: The term "ProductLine" adjoined to the "fW._oLstChoices" is the name of the prompt specified.
In case of change in the name take care to specify the corresponding name of prompt here as well.*/

/*The following script will check if the checkbox prompt is hidden or shown on page load, and will keep the same when clicked on the Finish Button*/

   var objDivCheck= document.getElementById("parentPrompt");
   var objOptionsCheck = objDivCheck.getElementsByTagName("OPTION");
   for (i=0;i<objOptionsCheck.length;i++)
   {
      if (objOptionsCheck.selected == true)
      {
         if(objOptionsCheck.innerText== "Mountaineering Equipment") //specify the name of the selection, for which you need to show the checkbox prompt. Here it is Mountaineering Equipment.
         {
            document.getElementById("childPrompt").style.display="block";

         }
         else
         {
            document.getElementById("childPrompt").style.display="none";

         }
      }
   }
</script>


Attached is the xml of the test report named HideShowPrompt. Please modify the package if needed.

Kindly let me know if anything else is needed or if the solution was helpful.


PRIT AMRIT

Great piece of work Amruta.... Keep it up.... 8)

kiran04

Hi Amrutha,
Thanks alot.. for the detailed explanation of the functionality of javascript  and I did my functionality by using validate function.. It worked.

var stsList =  fW._oLstChoiceStatus;/***Here Status is the name for the first prompt****/
fW._oLstChoicesStatus.onchange = validateChkBox;
stsList .options[1].selected = true;

function validateChkBox(){
         if(stsList .options[1].selected || stsList .options[3].selected || stsList .options[4].selected )
        {
                 document.getElementById("ChkBx").style.display = "none";
        }else{
               document.getElementById("ChkBx").style.display = "";
               fW._oLstChoicesunclProperty.checked= false
       }
</script>
<script>
validateChkBox();
</script>


Anyway..thanks again for the great explanation..
Thanks,
KWAS04.

Amruta Gandhi

Thanks all for your appreciation! :)

kiran04

Hi Amrutha,
I'm having another issue with the prompts in the report page. can u suggest me if javascript may help in this one.
The issue is that I'm having two value prompts in the report page as well as in the prompt page. They are cascaded prompts and they are working fine in prompt page but in the report page, when the first prompt is selected , it is directly running the report without hitting the finish button. But it is picking up the value in the second prompt.
note:
the two value prompts here are --required
the autosubmit is kept 'yes' for the first prompt in both the pages.
please , reply me with your suggestions to resolve this issue.

Vish

Thanx Guys...Its really COOL 8)

Amruta Gandhi

Hi KWAS04,

Sorry for being so late to see this...
Can you tel me what kind of filter is applied to the report? If report contains filter for only the second prompt then this might not occur. Also, the Autosubmit should be "No" for the second prompt.
Besides this, are both the prompts exactly same in the Report Page and the Prompt page? Coz if this is the case, then why should there be a reason to have the Prompt page separately? The users can select the prompts from the report page itself and execute the report. Please let me know if I have missed out anything.

kiran04

Hi Amrutha,
Yes,  your right , the user wants to run the report in report page itself without going back to prompt page, that is the requirement. Any how, I resolved the problem.

Please go through the below link
http://www.cognoise.com/community/index.php/topic,14735.msg46766.html#msg46766
There, you can check the details of the issue and  the solution.
And anyway thanks for replying back to me.

Thanks,
KWAS04.

xplorerdev

Hi Amruta,

Very informative post. Thanks a lot.

My report has 5 check box value prompts, one below the other. I have followed your comments and have pasted the HTML items and the corresponding codes within them. The first Prompt is working fine. I click on it, it gives a list of values with check boxes, I select multiple values from that list. Its all OK. BUT when I click on the second prompt, it again opens the first prompt. Similarly, when I click on 3rd, 4th or 5th prompt, it still opens up the first prompt. It seems that whenever a Value Prompt is clicked on, it opens the first Value Prompt.

Am I doing something wrong? Or the code is meant only for 1 Value Prompt? If that is the case then what I should probably do to make multiple Value Prompts functional?

Kindly advice.

Thanks n Regards
Dev

CognosPaul

I had a similar requirement not too long ago. My solution was slightly different, but will work well with multiple prompts.

Check out the post I wrote for PerformanceG2: http://performanceg2.com/2013/07/01/animated-drop-down-prompts-in-cognos/


If you're not on 10.2, you should be able to downgrade the report by changing "developer.cognos.com/schemas/report/10.0" to "developer.cognos.com/schemas/report/8.0"

xplorerdev

Hi PaulM,

You're the man. Thanks a lot. Your technique at http://performanceg2.com/2013/07/01/animated-drop-down-prompts-in-cognos/ works like a charm.  :)

Best Regards
Dev

frankrss

I have two questions:

1. If I have more than 2 prompt lists, how can I use the scripts posted on this thread?
2. for this link:  http://performanceg2.com/2013/07/01/animated-drop-down-prompts-in-cognos  , i can not download the files that mentioned there.

Thanks

CognosPaul

The links seem to work for me. They are txt files, so your browser may be attempting to do something weird with them. Try right click - save as. If that still doesn't work, I'll attach them to a post here.

Michael75

I can access Paul's PerformanceG2 article, via a slightly different URL:

http://www.performanceg2.com/blog/animated-drop-down-prompts-cognos/

Note that there's no "in-" before "cognos". Strange...

HTH
Michael