COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: dsmoljanovic on 27 Jul 2015 11:14:24 AM

Title: Search & Select prompt width - again
Post by: dsmoljanovic on 27 Jul 2015 11:14:24 AM
Hi all

I'm having similar problem as in this thread: http://www.cognoise.com/index.php/topic,26076.0.html
I want to fix the size of the search and select lists so they don't grow when text is longer then the width od the box (select item). With above js i managed to resize one box (right one - select), but it still does not work for result SELECT item. It always stays on 200px width and when search results are long (a long text) Cognos resizes it to really huge box.

So i want to fix it to 200px using JS, but don't know how.

Any ideas? Report studio 10.1.1.
Thanx
Title: Re: Search & Select prompt width - again
Post by: NIEK87 on 28 Jul 2015 01:16:21 AM
What if you change both the occurences of {selectObject[0].style.width = 'Auto';} from your code to {selectObject[0].style.width = '250';} ?
Title: Re: Search & Select prompt width - again
Post by: dsmoljanovic on 28 Jul 2015 04:50:12 AM
Yes i tried that. It works for second select object (selectObject[1]) which is the right one where you put wanted filters.
But it does not work for frist one (left one where your search results are displayed).

I'm guessing it overrides my javascript at some point later in page loading.
Title: Re: Search & Select prompt width - again
Post by: NIEK87 on 28 Jul 2015 06:22:55 AM
Oops! I didn't mean both the SelectObject[0], but both selectObject[0] and selectObject[1]. This works for me:

<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 = '250';}
if (selectObject[1] && selectObject[1] != undefined)
{selectObject[1].style.width = '250';}
}
}
</script>

Have you tried this?
Title: Re: Search & Select prompt width - again
Post by: dsmoljanovic on 28 Jul 2015 06:47:42 AM
Yes. :(
There is a fraction of a second during the page loading where i see it set as i told him but something then reset the sizes to default.

Could be due to Cognos version (10.1.1)?
Title: Re: Search & Select prompt width - again
Post by: NIEK87 on 28 Jul 2015 08:01:11 AM
I'm using RS 10.1.1. too, but it does work for me. Is it the only Javascript you have on the page?

I modified Paul's code a bit, this works for me as well:

html 1 (before the prompt):
<div id="MyPrompt">

html 2 (after the prompt):
</div>
<script>
  var e=document.getElementById('MyPrompt');
  var block1 = e.getElementsByTagName('select')[0];
  block1.style.width='250';
  var block2 = e.getElementsByTagName('select')[1];
  block2.style.width='250';
</script>
Title: Re: Search & Select prompt width - again
Post by: dsmoljanovic on 29 Jul 2015 03:28:04 AM
Nope. Something still resets it by the end of the page load.

I managed to do it with delayed start so i change the size after all other processing is done.

Something like this:
<script  type="text/javascript">
setTimeout(function(){
  var e=document.getElementById('MyPrompt');
  var block1 = e.getElementsByTagName('select')[0];
  block1.style.width='250';
  var block2 = e.getElementsByTagName('select')[1];
  block2.style.width='250';
},100);
</script>