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

Hiding Blocks as the User Selects in Report Author

Started by gosoccer, 06 Mar 2014 11:01:30 AM

Previous topic - Next topic

gosoccer

Friends,

I have two different Drop Down List on two different Blocks and I need to Grayout (Disable)the one Block on the left which includes the a Drop Down Listing when the user is Selecting the
Block on the right. Same way if the user selects the left Block, I need to clear the right block and make it
disabled. This way, there aren't two differen values from the Left Block and Right Block is not sent to the
main Query by acceident.

Even if I have two radio buttons, one for left and one for the right. If the user selects the left radion button, the Drop Down List will be available. If the user selects the right radio button, the right Drop Down List (Search and Select Box) will be available.

If you have any ideas, please share.

Thx so much in advance for your time.  :D

navissar

You'll need JavaScript for that. You can do either:
1. When one prompt has value the other is disabled and cleared; or:
2. When the user selected to use the first prompt, the second is cleared and hidden, and vice versa.

The script itself is quite simple and I can easily set you up with a rough sketch of the code. I just need to know your Cognos version (Slightly different approaches in 10.1 and in 10.2+, plus I want to give you an xml you can open) and whether you need scenario 1 or 2. Also, which prompts are you using (Single select, multi select, drop down, list box, radio buttons etc)?

gosoccer

Nimrod,
Thanks  so much for the reply,

I am using the Single Selection Radio Button on the Left Box and a single Seach/Select on the right part of the screen.
Please see the attachment.

Let me know if there is anyway I can be a help.


navissar

Well, there were in fact other questions I have asked. Your Cognos Version, for instance - Cognos 10.2 and up we can use Prompt API which makes life easier.
Also, you say you use radio buttons but your screenshot shows a list value.
Anyway, I made a mock up code for you - I can't give you an XML because I don't know your Cognos version. I made it so it'll work on all Cognos versions 10.1 and up. My code assumes the following:
1. You are in fact using a Radio button prompt and a SnS prompt, both single select.
2. The Radio Button prompt is named "left". If that's not the case you'll need to either change the prompt's name property or the script.
Step 1:
Put HTML Items around you prompts. Before your radio button prompt put in an HTML Item with the following:
<span id="RBPrompt">
and after it put in an html item with:
</span>
Before your Search&Select prompt put in an HTML Item with the following:
<span id="snsPr">
and after it put in an html item with:
</span>

If you change the IDs you'll need to change the script accordingly.

Step 2:
Add an HTML Item after the prompts, and paste in the following:
<script>
var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);
if ( !fW || fW == undefined)   
{
fW = ( formWarpRequest_THIS_ ? formWarpRequest_THIS_ : formWarpRequest_NS_ );
}
//get the SNS prompts' select list
var selectList=document.getElementById("snsPr").getElementsByTagName("select")[0];
//get the RB prompt
var RBPrompt=fW._oLstChoicesleft;

function checkIfPromptHasValue(fl){
ret=false;
if(fl==1){//the SNS prompt is clicked
if(selectList.selectedIndex>-1){
ret=true;
}
else{
ret=false;//you may have clicked, but you selected nothing
}

}
else{//RB Prompt is clicked
for(var i=0;i<RBPrompt.length;i++){
if(RBPrompt[i].checked){
ret=true;
break;
}

}
}
return ret;
}
function disableEnablePr(fl,dir){
if(fl==1){//selected prompt is SNS, need to disable RB
if(checkIfPromptHasValue(2)){//something is selected in RB Prompt
for(var i=0;i<RBPrompt.length;i++){
if(RBPrompt[i].checked){
RBPrompt[i].checked=dir?false:true;
break;
}
}
}
RBPrompt.disabled=dir;

}
else{//RB Prompt is selected, SnS needs to be disabled
if(dir){selectList.selectedIndex=-1;}//unselect
document.getElementById("snsPr").children[0].disabled=dir;
document.getElementById("snsPr").getElementsByTagName("input")[1].disabled=dir;
document.getElementById("snsPr").getElementsByTagName("button")[0].disabled=dir;
}

}
function main(fl){

//check if a value is selected in the prompt
if(checkIfPromptHasValue(fl)){
//disable the other prompt
disableEnablePr(fl,true);
}
else{
disableEnablePr(fl,false);
}
}
document.getElementById("RBPrompt").onclick=function(){main(2);};
document.getElementById("snsPr").onclick=function(){main(1);};


</script>


I tested this and it works on the scenario described here. Of course, if you have/make any changes, you'll need to adapt the script for them.
Enjoy.

gosoccer

Nimrod,
My apolgoies. We run 10.2.1 over here for our Report Author and Framework manager.
Yes, the Listing is the one we use and not the radio button.
Thank you in advance for your time.

navissar

Well, I'm afraid I am not going to hand over another solution. Here's why:
I write in this forum on my own free time. When you ask for a solution, I actually put in time into writing it - it's not all off the top of my head. This is time that I put in because I like this forum and the community, because I love banging my head against problems, and because I enjoy helping people learn and do really cool stuff. But it is still time - time I can spend doing work that I get paid to do, or with my family and friends, or sleeping, stuff like that.
This isn't something to be taken for granted, that people can post a question on the board and receive not just an answer, but actually have a full solution handed to them. There are lots of developers who need to browse through long tutorials and endless thread on Stack Exchange. In fact, Cognoise and the IBM Dev forum are two selling points I use when selling Cognos - the high availability of skilled, professional help.
Now, I wrote an answer that relied on your answers. It took me some time - not a lot, admittedly, but more than fifteen minutes. It wasn't trivial either - I didn't know whether I could use the prompt API so I had to take the long way, and S&S prompts are difficult to handle, and radio button prompts require looping through them because they don't support the selectedIndex method. I put in my own free time, my knowledge and experience to hand over a complete solution.
Then you change your answer, which means I need to change my code. I'm sorry, but I'm not going to do that, because that would mean spending more time and effort on this.
I think that when someone says to you: answer some simple question, and I'll hand you over a solution for free, you need to make sure you're giving the correct answer. It's the polite thing to do, and it strikes me as somewhat rude to take back an answer.
So, either wait to see if someone else here will be more willing to help; adjust the solution I already gave you to your real needs, or find some other way. Either way, I have delivered all the solutions I will deliver for this issue.


gosoccer

Nimrod,
I understand your concern and no please do not provide a new solution regarding to this issue.
I respect your work and others to a high degree and I hope one day I have enough expertise that
I can do the same. I think I have answered one or two but I need to do more and gain more expertise.

For the time you and others spend on this forum, you could be helping someone in different ways in providing
technical solutions and to be honest tutorial. 1) Someone under a very restrict deadline and if the person doesn't
provide a solution, he/she could loose their job. 2) Someone needs to provide an answer the next day to their
client or they face difficult situations. 3) Some tired of going through the manual and other materialsand not
getting anywhere. 4) Someone learning through your great work and the forum and findinga way to establish a
career since he or she is learning the materials quicker and easier.

I can name so many scenarios that explains how important is your work and how much we do NOT
take it as granted.

Have wonderful day and thank you so much for your time. I'll do my best to help this forum also. It is a precious
place.

:)

gosoccer

Nimrod,

Unfortunately, I am getting the following error.
I put the "RBPrompt" under the "name" associated to the LIST BOX in the property sheet under the Miscelaneous.
Is that correct?

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; InfoPath.3; .NET4.0C; .NET4.0E)
Timestamp: Tue, 11 Mar 2014 13:31:09 UTC


Message: 'RBPrompt.length' is null or not an object
Line: 236


Thx in advance for your time.

gosoccer

OK,

It looks like it's working now. The name of the prompt is left for the List Box on the left. I'll findout what is the name
to the right object (the search and select object)

Thank you,

navissar

Quote from: Nimrod Avissar on 08 Mar 2014 07:59:49 AM
My code assumes the following:
1. You are in fact using a Radio button prompt and a SnS prompt, both single select.
2. The Radio Button prompt is named "left". If that's not the case you'll need to either change the prompt's name property or the script.


:)

gosoccer

Thank you again Nimrod,
Well Nimrod,
Unfortunately, with using the parameter from FM Model Subj. Query ((AUDIT_SESSION.SITE_ID = #prompt('REPORT_SITE')#)), I CAN NOT set it up the drop down listing as an optional (Optional in the Filter) in the Report Author Report. The report doesn't allow it unless there is a trick involved. In fact, even by overwriting the submit using the HTML Item/Java Script like below, } else if ( RPDScripts.getControl('left').getValues().length > 0) { promptButtonFinish ();

The reason I need the Drop Down List to be optional since I have two of them in the same prompt screen as the attachment shows. So the user can select the Left box and run the Report or the Right Search/Select to run the report.

In this case, if the user selects the left side and wants to Run Report, since the Right Search and Select Box doesn't have the user entry, it comes back with the ugly "One or More Required Value is Missing" Message.

The reason I can't use parameter within the filter of the Report Author instead of the prompt from the FM Model Sub. Query, is due to the performance. It took less than a minute to get the data with the FM Model Subj. Q. instead of the 3 minutes when the filter/parameter used in the Report Query - Filteration using the ?REPORT_SITE? option.

gosoccer

OK, Got it working using FM Model Optional Parameters (DefaultText)
Have a great day!
:)

gosoccer

OK,
I'm going to bug you one more time. Do I need to give it name for the snsPr as a part of
the report?
The JS debugger is sending me to this item.

var selectList=document.getElementById("snsPr").getElementsByTagName("select")[0];
Thx,

navissar

Please read the instructions thoroughly.

Quote from: Nimrod Avissar on 08 Mar 2014 07:59:49 AM
Step 1:
Put HTML Items around you prompts. Before your radio button prompt put in an HTML Item with the following:
<span id="RBPrompt">
and after it put in an html item with:
</span>
Before your Search&Select prompt put in an HTML Item with the following:
<span id="snsPr">
and after it put in an html item with:
</span>

gosoccer

Nimrod,
I have the HTML items around the prompt. Couple small questions.

1) Do I need to put snsPr under the Search/Select Misc property?
2) If you a List Item and not a Radio Button Listing, would the code be any different?
3) for the main HTML file, we need to have it twice, right? after each prompt?


navissar

Quote from: gosoccer on 12 Mar 2014 02:26:19 PM
Nimrod,
I have the HTML items around the prompt. Couple small questions.

That doesn't mean it has the code I wrote it needs to have...
Quote from: gosoccer on 12 Mar 2014 02:26:19 PM
1) Do I need to put snsPr under the Search/Select Misc property?
No.

Quote from: gosoccer on 12 Mar 2014 02:26:19 PM
2) If you a List Item and not a Radio Button Listing, would the code be any different?
yes.
Quote from: gosoccer on 12 Mar 2014 02:26:19 PM
3) for the main HTML file, we need to have it twice, right? after each prompt?
No. The script does the whole thing.

gosoccer

For using the Radio Button Group, works just fine Nimrod. After selecting one of the items, it Grays out the right Search/Select Box. The client doesn't want to use Radio Button Listing so I have to provide them the List Box. Thx,

navissar

Hi,
I'm going to give you a solution. It's not the best or most efficient, but it will work. It's at the bottom of this message. You can skip this message, and just take the solution from the bottom. However, I do ask that you read what I have to say:
I point you again to my message at the beginning of this thread: I feel very uncomfortable with the way this thread took.
The bottom line is this: I wrote an answer that relied on your answers and definitions. It took me time, and it wasn't trivial, which means it took some expertise. So really, I put in my own free time, my knowledge and experience to hand over a complete solution. Then you changed your requirement, and you expect that I deliver a brand new solution, matching your new requirement.
I love roaming around the pages of this board, I love the handing over of solutions as well as the learning and teaching, I love that I know that if I'm ever stuck, people here will help me, and I love helping other people here. What I don't appreciate, however, is feeling that it is taken for granted or that it's undervalued, or taken advantage of.
I started my comments in this thread promising you that I will give you a full solution, if you answered a couple of question.
Think about this for a second. You have a problem you need to deal with at your work. You post your problem on a board on the internet. You don't even leave your chair, and 5 hours later a complete stranger - someone who could be half the world away (I don't know where you're from. I'm from Israel, personally) - makes your problem his and promises you a solution.
Think about it some more. Developing specialized solutions for Cognos isn't my hobby. I do this for a living. Developing Cognos and other BI stuff is how I feed my daughter and make mortgage. Developing specialized Cognos solutions is how I made myself a career. That's why people pay me what i ask instead of taking someone who's less experienced for less money. That's my edge. If you were my customer, I'd charge you for a solution like this. But since you're a person I don't know on a board, I give you my time and knowledge for nothing but a smile.
So I happily put in the time - and like I wrote, this should not be taken lightly - based on your answers to my questions. Then, after I do that, you change the answers, quite matter-of-factually, even. You're basically saying "Hey, thanks, but i actually need something else, please give me that".
Take a look at the wording of your latest comment. "The client doesn't want to use Radio Button Listing so I have to provide them the List Box. Thx,".
This sounds like a demand more than a request. It's as if you're saying "Oh, this works, but I need it done otherwise OK? Thanks. Bye".

Suppose you were a restaurant owner. And since you're a good person, kind person, you'd let the less fortunate who come in after hours to eat for free. That's mighty nice of you, isn't it?
Now suppose one person comes in. You welcome them and say "Today I can offer you chicken or fish". The person says "Thank you. I'll have the fish". You go to the kitchen, take out what's left of the fish, fix it up nice, do some work. You then serve the fish. The person you're feeding takes a bite and says "You know what, I feel like chicken really. Be a lamb and fix me some chicken, will you?". Wouldn't that make you feel a tad irritated? That your work is taken for granted?

It's really quite the same, only with code instead of food.
So I just ask you this: Next time, please be clear and precise. Specify precisely what you need (if you're not sure, consult with your customer), and your exact scenario. Don't let anyone else or me feel like you've just thrown away their fish.



Oh, yeah, the solution: In the main script replace any occurrence of the word "checked" with "selected". That should do the trick.

Lynn


MFGF

Thanks Nimrod for all your donated time, skills and intellect. We are hugely appreciative!!

MF.
Meep!

navissar

I appreciate it Mark. However, this isn't why I wrote my comment. It's not recognition I'm after, but clarity in future questions.
The main advantage of this forum is that people in it are so eager to help they hand out solutions to difficult problems. That's great - information wants to be free. I just want to make sure it's not used as a personal "Genius Bar"  ;)