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

Select & Search prompt option default selection customization

Started by pcog, 13 Dec 2013 09:55:36 AM

Previous topic - Next topic

pcog

Hi all,

Originally I posted this issue in Cognos 8 forum.

"I have requirement to change the default selection of Cognos Select & Search prompt. By default Cognos will select the 'Start with any of these keywords', but user requested to have default option of 'Contains any of these keywords'. They also want to remove the other options, but I can negotiate with that if I get the default option per requirement.
I found KB technote 1372246 and 1341747, but those are not working, may be because those are not for 8.4.1."

Does anyone had this req before or can anyone help me out here?

navissar

Hi,
You didn't mention which version you're using. I'm attaching a working sample in 10.1.
If you want to hide the whole thing, as you indicated, you can open up the script HTML item and this code right before the </script> tag - this would hide the "Options" link, so no one will be able to open it.
var theTDs=theDiv.getElementsByTagName("td");
for(var k=0;k<theTDs.length;k++){
if(theTDs[k].className=="clsOptions pe"){
theTDs[k].style.display="none";
}
}

Please find attached the XML sample.

pcog

Hello Nimrod Avissar

Thanks for your reply.
Sorry, we are using 8.4.1.
As I mentioned in my previous post, I found the KB technotes on this, but those are not working for 8.4.1. I can't even use/open your script since it is in 10.1
Can you please provide me the java script for 8.4.1?

navissar

Hey,
Sorry about that, you got me confused (This is the Cognos 10 forum, but I should have seen that you wrote you've already posted in the Cognos 8 forum). Anyhow, I don't have an installation of 8.4.X available, but I'll give you the general structure - I've used it many times in 8.4 and up, and it works perfectly.

Drag in the following object in this order: HTML Item, search and select prompt, HTML item, HTML item. Set your S&S prompt as you would normally do.
Now, in the first (leftmost) HTML Item type in the following:
<div id="mySearchAndSelectPrompt">
In the second HTML item (The first one to the right of the S&S prompt) put in:
</div>
In the last (rightmost) HTML item paste in the following code:
<script type="text/javascript">
function printObject(o) {
var msg = "";
for (field in o) {
msg += field + ":" + o[field] + "\n";
}
alert(msg);
}
var theDiv = document.getElementById("mySearchAndSelectPrompt");
// find all the children of the DIV
for (i=0; i < theDiv.childNodes.length; i++)
{
// find the input TAGs and set checked where appropriate
var node_list = theDiv.childNodes[i].getElementsByTagName('INPUT');
for (var j = 0; j < node_list.length; j++)
{
// if (node_list[j].id.indexOf('swsStartAny') !=-1) // checked is true by default
// if (node_list[j].id.indexOf('swsStartAll') !=-1)
if (node_list[j].id.indexOf('swsMatchAny') !=-1)
// if (node_list[j].id.indexOf('swsMatchAll') !=-1)
// if (node_list[j].id.indexOf('swsCaseInsensitive') !=-1) // checked is true by default
{
// printObject(node_list[j]);
node_list[j].checked = true;
}

}

}


</script>


If you wish to hide all the options add the code I posted earlier right before the </script> on the last HTML item.

Good luck!

pcog

Thanks Nimrod for your reply. It is working perfectly alright.
I also used the other script to completely hide the options for the prompt.

To all who needs this thing to work, the script mentioned in previous post should work for sure (at least 8.4.1), if not try the below one.
I got a reply for my post in C8 forum and the script he suggested should work for all cognos versions and it is very simple too.
Put an HTML item before the prompt with: <div id="mySnS">
Put another HTML item after the prompt with </div><script>document.getElementById('mySnS').getElementsByTagName('input')[4].click();</script>
That should select "Contains any" in all versions of Cognos.
(Courtesy 'CognosPaul')

Thanks