COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: adik on 08 Jan 2014 08:31:40 AM

Title: Cognos 10.2 remove first two options from a dropdown list
Post by: adik on 08 Jan 2014 08:31:40 AM
Hi all,

I would like to know if there is any way to remove the first two options of a dropdown list, in Cognos 10.2, using the JavaScript API?
I know how to do this using the selection of the DOM element, but since there is an API for selecting the prompt, I want to know if there is the possibility to go that route also.

What I found was that I can get to the DOM element using the prompt API like so:
var oCR = cognos.Report.getReport("_THIS_");
var myPrompt = oCR.prompt.getControlByName("MyPrompt")._eE;

and then I can do:
myPrompt.remove(0);
myPrompt.remove(1);

This works in Cognos 10.2, but in Cognos 10.2.1 this doesn't work as the DOM element reference seems to be renamed to something like: var myPrompt = oCR.prompt.getControlByName("MyPrompt")._eL;

So is there any other way of doing this without relying of the nodes like _eE and _eL ?
Title: Re: Cognos 10.2 remove first two options from a dropdown list
Post by: MFGF on 08 Jan 2014 09:00:18 AM
Hi,

When you refer to removing the first two options, do you mean the title and the dotted line? If so, simply go to the properties of the prompt and set the Header Text property to "Specified Text" without entering anything for the text.

If you are trying to remove the first two data values from the prompt, why not just go to the query underpinning the prompt and add a filter to remove these items from the query?

MF.
Title: Re: Cognos 10.2 remove first two options from a dropdown list
Post by: adik on 09 Jan 2014 01:08:58 AM
yes, i was reffering to the prompt name and the minus signs.
the header text did the trick. i didn't know they included this property as cognos 8 didn't have it and you needed javascript for that.
thanks
Title: Re: Cognos 10.2 remove first two options from a dropdown list
Post by: adik on 09 Jan 2014 01:42:51 AM
while on the topic I have another question: how do you reach the DOM elements of a prompt using the Prompt API?
more exactly I want to add an onclick event to a value prompt (dropdown list)
Title: Re: Cognos 10.2 remove first two options from a dropdown list
Post by: navissar on 09 Jan 2014 06:39:05 AM
Hi,
You can trigger an onchange event by using the prompt API's setValidator function. The setValidaor() function checks the prompt when it is changed (A new value is selected/old value is deselected etc) and runs a function. Its intended use is to create a validation mechanism, but you can trigger any function, and then just return "true" to enable submit.
Title: Re: Cognos 10.2 remove first two options from a dropdown list
Post by: adik on 09 Jan 2014 01:05:38 PM
perfect, thanks for the help