If you are unable to create a new account, please email support@bspsoftware.com

 

Javascript to refersh the report page, once a value is selected in a tree promt

Started by xyz, 07 Nov 2013 07:19:46 AM

Previous topic - Next topic

xyz

Hi Gurus,

Anyone has a javascript to refresh the report page, once a selection is made in the tree prompt?



Thanks & Regards,
xyz

xyz

I found the java script to get submitted once the selection is made in tree prompt. In Cognos Paul blog. I followed the steps and it worked for me. You are awesome, Paul.

Add the HTML to the left of the tree prompt and add the piece of code below in it.
<div id='myTree'>

Add the HTML item to the right of the tree prompt and add the piece of code below in it.
</div>

Add one more HTML item to the the right of the tree prompt, after the above HTML item and add the piece of code below in it.

<script> document.getElementById('myTree').onmousedown=function(){runTree('MyTreePrompt1')}; </script>

Where 'MyTreePrompt1' is the name given to the tree prompt.

Add one more HTML item to the the right of the tree prompt, after the above HTML item and add the piece of code below in it.

<script> function runTree(id) { 
t=setTimeout('checkTree("'+id+'")',200);
} </script>

Add one more HTML item to the the right of the tree prompt, after the above HTML item and add the piece of code below in it.

<script> function checkTree(id) {   selectedTreeNode  = window.treeMyTreePrompt1.getLastSelectedNode();   if(!selectedTreeNode) {return}   promptButtonFinish(); } </script>

It will work as expected.

Thanks & Regards,
xyz

CognosPaul


xyz

Hi,

I am facing issue with the java script as when we upgraded  10.2.1.1. The issue I am facing is tree prompt is shown by default instead of hidden in the report page. When I tried to add below java script for default hiding of the tree prompt, expanding the member in the tree prompt is taking too much of time.

<a href="JavaScript:ShowHide()"><font size="1">&nabla;</font></a> -- clicking on down arrow symbol tree prompt will get hide and unhide, which is calling the ShowHide() function, which is used after the span tag

<span id="myTree" "display:none">  -- span tag is used before tree prompt and ended with </span> after the tree prompt.

<script language="javascript">
function ShowHide(){
var el = document.getElementById("myTree").style.display=document.getElementById("myTree").style.display=='none'?'block':'none';
                  }

</script>

Can some one please help me, how to hide the tree prompt by default in the report page for 10.2.1.1, which will not result in the performance hit when expanding the tree prompt.

CognosPaul

That JavaScript shouldn't have any impact on the functionality of the tree prompt. If you remove the script, the tree prompt opens faster?

Is it possible the previous script is causing the problem? My backend API has changed a bit, and I haven't had the chance to test my old solutions in 10.2.1.

xyz

Hi Paul,

Yes, when I remove the "style.display: none" property from <span> tag, expanding the member are working faster.

Actually the script was working absolutely fine with 10.1.1 version of Cognos, upgarding to 10.2, performance issue was happening then I changed the <div> tag and used the <span> tag around the tree prompt. In process of that I removed the document.getElementById("myTree").style.display='none' property in one of the HTML item as well.

Now, when I try to add document.getElementById("myTree").style.display='none' property, script is not working and when I use  "style.display: none", expanding the members of the tree prompt is causing issue.

Can you please help me on the same.

Thanks & Regards,
xyz

xyz

Hi All,


Basically the requirement is, we have a tree prompt in the report page, which has to be hidden by default in the report page. And when we select the member in the tree prompt, report has to get submitted as well as tree prompt should be get hidden, when the value is selected in the tree prompt.

Attached is the Java script code difference between Cognos 10.2.1.1 and 10.1 version, as well as the screen shot of the HTML Items used in the report.

In Java script using var el = document.getElementById('myTree').style.display='none'; is causing the performance issue, when expanding the members in the tree prompts is taking 40 to 45 seconds, which is a performance issue in Cognos 10.2.1.1 version, I tried hiding the tree prompt in the <span> tag using style="display: none:" also causing the same performance issue, when expanding the members in the tree prompt, it is taking almost 40 to 45 seconds.

Anyone's help would be greatly appreciated.

Thanks & Regards,
xyz

   

CognosPaul

Can you post the report xml? Delete everything except the tree prompt and html items.

xyz

Thanks for the reply, Paul.

Please find the attached xml with tree prompts and related HTML items.


Along with that I have one question Paul, I have a calculation for WTD, QTD, Period To Date (PTD) and YTD in my report, I was able to get the calculation easily done for WTD, QTD and YTD. where I am struggling to get the data correct for Period To Date calculation, which is nothing but Month To Date. If I pass Week as parameter in PTD calculation, I have to display days for that month on the x-axis. I tried creating calculation like below.

periodsToDate ([MMHF].[Date].[Hierarchy - Fiscal Year].[Date - Fiscal - Month], [MMHF].[Date].[Hierarchy - Fiscal Year].[Date - Fiscal - Week]->?p_fiscal_week?)

But it is not working as expected, can you please help me on it.

Example: Calculation used for QTD looks like below
periodsToDate ([MMHF].[Date].[Hierarchy - Fiscal Year].[Date - Fiscal - Quarter], [MMHF].[Date].[Hierarchy - Fiscal Year].[Date - Fiscal - Week]->?p_fiscal_week?)

WTD, QTD  and YTD calculations are working as expected.

Your help is much appreciated :)


Thanks & Regards,
xyz

xyz

Hi Paul,

I am eagerly waiting for your reply, which will make my day in India as it is very urgent and important to me, if we don't have solution for Java script for now, it's okay but for PTD calculation is of high importance and report has to be delivered to the client today.


Thanks & Regards,
Xyz

MFGF

Quote from: xyz on 16 Jan 2014 09:13:05 PM
Hi Paul,

I am eagerly waiting for your reply, which will make my day in India as it is very urgent and important to me, if we don't have solution for Java script for now, it's okay but for PTD calculation is of high importance and report has to be delivered to the client today.


Thanks & Regards,
Xyz

<Moderator hat on>

Xyz, please don't try to push forum members into replying like this. People who post on here try to be as helpful as they can, but they are professionals with full time jobs and they are kind enough to provide help when they get chance in their busy working day or often outside their working day. Many people are offended by posters that seem to be "pushy" and demand answers within short timescales. I appreciate that you have a deadline, but it can be perceived as rude and arrogant to push someone who has already offered you so much help freely.

<Moderator hat off and Muppet hat on>

You might get better responses if you provide more information - saying "it is not working as expected" doesn't indicate what the issue might be. Is it returning an error? If so, what is the error? Is it returning the wrong members/the right members in the wrong order/some of the right members/etc? If so, what is it returning and how is it not as expected?

Cheers!

MF.
Meep!

xyz

My apologizes,

Sorry for the rude behaviour, because of the deadline I behaved rudely, I should have done that way. It will be taken care.
Next time, I will give clear details, what is the issue I am facing and what is working, what is expected?

By the way the issue has been resolved for PTD calculation.



Thanks & Regards,
xyz

MFGF

Meep!

CognosPaul

The issue is related to how you're calling the ShowHide function. The anchor tag should have "#" as the href, and the function call should be in an onclick event.

Try:
<a href="#" onclick="ShowHide()"><b><font size="1">&nabla;</font></b></a>

As it stands, it looks like the report is somehow losing it's connection to the session.

xyz

Hi Paul,

Thank you very very much for the solution, you are really awesome man :). Solution worked like a piece of cake.



Thanks & Regards,
Xyz

xyz

Hi Paul,

I have one question regarding the java script, which I have provided xml earlier. Actually my client have a new requirement now, whenever a selection is made in the tree prompt. The tree prompt will get hidden with the selection made by the user but  what user want to see the selection again, where selected tree prompt members in the tree prompt without being collapsed instead of collapsed members. Can we have the last selection with the selected member in the tree prompt without the tree prompt member collapsed.

Thanks in Advance.

Thanks & Regards,
Xyz

xyz


CognosPaul

Hi Xyz,

This request has been around for a long time. I tried hacking into the code that controls the tree prompts, but I haven't been able to figure it out.

Tree prompts only have the top level visible on the page when it first loads. Each time a member is expanded it runs a request to the data source to get the children. As far as the browser is concerned, the children don't actually exist until the tree prompt fetches them. Unfortunately this means that it needs to be submitted to IBM as an enhancement request. The more people that request it, the more likely it is to actually get done.

xyz

Thank you very much Paul for spending time to help me resolve my problem.

Your help is really appreciated.

In that case, I have to raise the ticket with IBM for the same.



Thanks & Regards,
Xyz

jeeva

Quote from: CognosPaul on 20 Jan 2014 04:05:54 AM
The issue is related to how you're calling the ShowHide function. The anchor tag should have "#" as the href, and the function call should be in an onclick event.

Try:
<a href="#" onclick="ShowHide()"><b><font size="1">&nabla;</font></b></a>

As it stands, it looks like the report is somehow losing it's connection to the session.





Hi Paul,
we also have same issue. as u said it is working fine after changing the script. But why cognos 10.2 taking to much time to expanding the tree prompt. and what is the difference between these below code
<a href ="#" onclick="function()"> and <a href="function">