COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: dannygutters on 11 Aug 2010 03:51:34 PM

Title: Tree Prompts with java script on page
Post by: dannygutters on 11 Aug 2010 03:51:34 PM
I have a prompt page with both a tree prompt and a search and select box. I added some javascript to resize the results pane of the search and select box.

But when I include this resize code it causes the other tree prompt to render blank. Any ideas on what is happening here? Is there a way to have cognos redraw the tree prompt correctly while still alowing me to modify the search box size? I don't see why it's affecting the tree since everything in the javascript is modifying an associated div.

something like:
<script>
getelementbyid(mydiv)
Find the node within mydiv object that starts with TYpe (search box)
get the element by id here (gets the search box)
set it's width to 500
</script>
Title: Re: Tree Prompts with java script to resize search and select prompts on page
Post by: rockytopmark on 26 Sep 2011 09:56:25 AM
I am experiencing this exact problem myself.  If anyone has worked through this issue, please do share!!

Thanks... Mark
Title: Solution to problem in Tree Prompts w/javascript on page to size Search prompts
Post by: rockytopmark on 26 Sep 2011 11:43:12 AM
Working with a post on a different forum, I was able to produce a solution.  Thanks to "Ajitha" for the starting point...

I have this working in my 8.4 environment.  As I have many prompt controls, I have altered the solution as follows so as to re-use the function for any prompt to be re-sized by adding a parameter to be passed in related to the object name (DIV):


1.   Add an HTML item to the top of the Page Body and include the following code in it:

<script language="javascript">
function resizeSS(prmt_id)
{
var eleTg1 = document.getElementById(prmt_id);
var selectObject = null;
if (eleTg1 && eleTg1 != undefined)
{selectObject = eleTg1.getElementsByTagName('SELECT');
   if (selectObject[0] && selectObject[0] != undefined)
    {selectObject[0].style.width = 'Auto';}
   if (selectObject[1] && selectObject[1] != undefined)
    {selectObject[1].style.width = 'Auto';}
}
}
</script>



2.   Before each and every Search and Select prompt control to be auto-sized, add an HTML item and insert the following code in it, changing prompt_name for each control so that it is named meaningfully and unique:

<DIV ID="prompt_name">




3.   After each Search and Select prompt control to be auto-sized, add an HTML item and insert the following code in it, changing prompt_name for each control so that it is using the name given in the DIV tag in the HTML Item before the prompt:

</div>
<script language="javascript">
resizeSS('prompt_name');
</script>




I should also note where the fixed width pixel values of 600 were replaced with 'Auto'
...this will automatically expand the width of the object based on the search results/selections.

M
Title: Re: Tree Prompts with java script on page
Post by: MFGF on 27 Sep 2011 04:03:13 AM
Cool!  Thanks for sharing the solution Mark! Very much appreciated!

MF.