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

Value prompt font

Started by Ammus1234, 30 May 2014 04:36:29 AM

Previous topic - Next topic

Ammus1234

Hello All,

Is there any way to display some values in value prompt as bold as shown below and these values are not selectable by users.
It is like a category heading. All the values in the value prompt are static choices.

Geography
   Zone
   Country
   State
Customer
   Name
   Address

Thanks in advance.

Satheesh

Hi,


You can achieve this by using JavaScript.




Thanks & Regards
Sateesh

Ammus1234

Thanks Satheesh for the reply.
I am not so good in Javascript.  :(
It would be helpful if there is any example available for Javascript? If I can use Prompt API?

Satheesh

Hi


Ok let give some time, even I didn't have that. I will do and will provide you soon.




Thanks & Regards
Sateesh
Mumbai

Satheesh

#4
Hi,


In JavaScript font is not working as exactly may be due to browser issue also, I can suggest you to make background color and text color instead of Bold font. for this code is below....


<script type="text/javascript">




var dd = document.getElementsByTagName("option");
for(var i=1; i<=dd.length; i++)
{
if(dd.getAttribute("dv") == "Geography" || dd.getAttribute("dv") == "Customer")
{


dd.style.color="red";
dd.style.backgroundColor="yellow";
dd.style.fontSize="large";
dd.style.fontWeight="bold";


}


}


</script>



Thanks & Regards
Sateesh
Mumbai




navissar

Right,
Satheesh's code is good, but it doesn't cater for the main thing - disabling the selection of the value.
First of all, straight off the bat, I'd give up styling the list - IE is crap and it doesn't support styling a list value option.
Also, I'd use the promptAPI to catch the DOM object, just for future compatibility (If changes are made to the formWarpRequest in future versions).
Now, you mention your prompt is all static choices. Since it's static, and since we don't want to select a "title", I suggest that you give the same use value (I used 0) to all titles (Instead of locating them one by one as in Satheesh's code.
Replace "test" with your prompt name below, this'll disable your title values (But unless on FF or Chrome you will not be able to style them):
<script>
var RNA = {};
RNA.getControl = function(promptName)
{
  var ocr = cognos.Report.getReport("_THIS_");
  return ocr.prompt.getControlByName(promptName);
};
var thePrompt=document.getElementById('PRMT_'+RNA.getControl('test')._id_).innerHTML;
var theOptions=document.getElementsByTagName('option');
for(var i=0;i<theOptions.length;i++){
if(theOptions[i].value==0){
theOptions[i].disabled=true;
}

}
</script>

Ammus1234

Thank you Nimrod  :)
I will give it a try and come back.
I am using IE only. I did notice that none of my scripts are running in Firefox or Chrome.

Thanks Satheesh for your time. I am using Prompt API in the report.

Ammus1234

Hi Nimrod,

Thanks for the code. It works perfect.  :)
Can you please tell me how can I style the text inside the value prompt even though it is not working in IE.

navissar

Check this piece of code out:
for(var i=0;i<theOptions.length;i++){
if(theOptions[i].value==0){
theOptions[i].disabled=true;
}

This loops through the options, and disables the options with value=0.
You can add further modifications such as:
for(var i=0;i<theOptions.length;i++){
if(theOptions[i].value==0){
theOptions[i].disabled=true;
[b]theOptions[i].style.color="red";[/b]
}

Ammus1234

Thanks Nimrod.

When I make it disabled I can't make it bold. It's grey by default.
Otherwise styling is working.

Satheesh

Hi,


1. First U need to know, to remove parameter name and dashed line (first two default options) no need Javascript. IBM provided in built property for that on 10.x on wards.


Under Value prompt Properties: ---> Prompt Text --> Header Text --> select Specify text radio button(don't specify anything) and Click ok.


2. HTML won't support styles in select options, so bold characters won't come in Value prompt.




Thanks & Regards
Satheesh Chapparapu
Mumbai

Ammus1234

Satheesh,

I was trying to create a category list with category names in bold and disabled.
Styling is possible in value prompt. You can try Nimrod's code from above post. It works.

MDXpressor

Is there a reason why cascading prompts isn't being employed here?

Why do you have what seems to be 2 different dimensions served by the same prompt?

What are you ultimately trying to accomplish?  Perhaps there is a more generic way to accomplish your goals.  Contrary to popular belief, complicated is not better.  Especially when it comes to long term maintenance.  CognosPaul and david.stachon may hate me for saying this, but adding .js to your reports is risky for the business.  If you are hit by a bus, and your .js needs maintenance, you have just reduced the pool of resources who could maintain your content to those who not only know Cognos, but must also know .js.

Don't get me wrong, .js can introduce many great features, but simple business people can't decode/debug .js.  Worse, with .js in your report, if the .js fails, the errors that Cognos gives back can be difficult to understand, making troubleshooting a nightmare.  Most users are best off considering .js to be a four letter word and steer clear of it. 

...my 2 cents.
No, a proof is a proof. What kind of a proof? It's a proof. A proof is a proof, and when you have a good proof, it's because it's proven.

-Jean Chretien

MFGF

Quote from: MDXpressor on 16 Jun 2014 11:06:49 AM
Contrary to popular belief, complicated is not better.  Especially when it comes to long term maintenance.  CognosPaul and david.stachon may hate me for saying this, but adding .js to your reports is risky for the business.  If you are hit by a bus, and your .js needs maintenance, you have just reduced the pool of resources who could maintain your content to those who not only know Cognos, but must also know .js.

AMEN. I think you can also read my thoughts! ;)
Meep!

Ammus1234

I second that.
But sometimes we don't have an option other than .js
Otherwise IBM has to come up with some new generation user friendly prompts.
I could never use a tree prompt or multi select prompt on a report page without a js


MDXpressor

What are the common things you'll do to a tree prompt in .js?  I'm looking for a solution which will expand a tree prompt to the current selection when the page reloads.

Actually, don't answer that here, I'll open a new thread...
No, a proof is a proof. What kind of a proof? It's a proof. A proof is a proof, and when you have a good proof, it's because it's proven.

-Jean Chretien