COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: cwillard on 17 Mar 2016 06:36:08 AM

Title: Wrapping text in a value prompt with Javascript
Post by: cwillard on 17 Mar 2016 06:36:08 AM
We have several fixed with prompt boxes the result in the text values being cutoff inside the box.  We have been using the following Javascripts in Cognos 8 which wrapped the test in the box.  We are finally upgrading to Cognos 10.2.2 and have found the text is no longer wrapping.  I am not a Javascript expert and would appreciate any suggestions on how the script below should be changed so it will work in Cognos 10.2.2.

This script is put in an HTML item at the top of the prompt page
<script>
var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);
if ( !fW || fW == undefined)
{

    fW = ( formWarpRequest_THIS_ ? formWarpRequest_THIS_ : formWarpRequest_NS_ );

}
var preFix = "";
if (fW.elements["cv.id"])
{

    preFix = fW.elements["cv.id"].value;

}
var nameSpace = "oCV" + preFix;
</script>

The Second script is placed in an HTML item next to the prompt box needing the text wrapped.  In this case the prompt box is named _whichCancerType
<script>
if(fW._oLstChoices_whichCancerType) {var wc = fW._oLstChoices_whichCancerType
, wcLen = wc.length?wc.length:0;

for (var i=0;i<wcLen ;++i){
  wc.parentNode.setAttribute('title',wc.parentNode.innerText)
  wc.parentNode.parentNode.style.width='100%';
  wc.parentNode.parentNode.style.whiteSpace='normal';
  wc.parentNode.parentNode.style.display='inline-block';
  wc.parentNode.childNodes[1].nodeValue=wc.parentNode.childNodes[1].nodeValue.replace(/\xA0/g,' ');
}
}
</script>
Title: Re: Wrapping text in a value prompt with Javascript
Post by: tkjenkin on 17 Mar 2016 02:36:56 PM
We put a html item with the div tag before the prompt with this inside:  <div id="BR"> then another html item after the prompt with this:  </div>
<script language="javascript">
setSaSoptions("BR");
resizeNameSS("BR");
</script>

In this example we are using the Search and Select prompt.
Title: Re: Wrapping text in a value prompt with Javascript
Post by: cwillard on 17 Mar 2016 08:03:13 PM
Thank you for the reply but unfortunately it does not seem to work for the checkbox and radio button prompts.