COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: venkiatmaruthi on 03 Mar 2011 04:24:24 AM

Title: Cognos 8.4: Javascript working from Report studio but not from Namespace
Post by: venkiatmaruthi on 03 Mar 2011 04:24:24 AM
Hi,

I am having the problem with javascript that shows the tabs at right top corner in the report.

When I run from Report studio it works fine.
But when I run from Namespace it's not showing SHOW/HIDE prompt.


below is the code:
<HTML>
<script>


if(typeof(oCVRS) != "undefined")
{
oCVRS.rvMainWnd.setToolbar({"namespace":"RS","divId":"CVToolbarRS","style":"toolbar","S":[
{"P":{"Y":"vertical_line"}},
{"I":{"N":"logOnOff","M":{"id":"logOnOffoCVRS","Y":"dropDown","H":"true","IS":[{"I":{"N":"logOff","E":"Log Off","C":"/Cognos8/skins/corporate/branding/tools_logoff.gif","A":"oCVRS.getRV().authenticate(\"logoff\", \"/Cognos8/cgi-bin/cognosisapi.dll?b_action=xts.run&m=portal/logoff.xts\");"}}]}}},
{"P":{"Y":"vertical_line"}},
{"B":{"N":"showhide","A":"showhide();","O":"Show/HidePrompts","C":"/Cognos8/rv/cvxToolbar/ShowPrompt.jpg"}},
{"P":{"Y":"vertical_line"}},
{"B":{"N":"SaveAsReportView","A":"oCVRS.getRV().SaveAsReportView(false);","O":"Save as Report View","C":"/Cognos8/rv/images/action_save_report_view.gif"}},
{"P":{"Y":"vertical_line"}},
{"B":{"N":"sendReport","A":"oCVRS.getRV().SendReport(false);","O":"Email Report","C":"/Cognos8/rv/images/action_send_report.gif"}},
{"P":{"Y":"vertical_line"}},
{"B":{"N":"runReport","A":"oCVRS.getRV().RunReport();","O":"Run","C":"/Cognos8/rv/images/action_run.gif"}},
{"P":{"Y":"vertical_line"}},
{"B":{"N":"drillDown","A":"oCVRS.getDrillMgr().rvDrillDown();","O":"Drill Down","C":"/Cognos8/rv/images/action_drill_down.gif","D":"true"}},
{"B":{"N":"drillUp","A":"oCVRS.getDrillMgr().rvDrillUp();","O":"Drill Up","C":"/Cognos8/rv/images/action_drill_up.gif","D":"true"}},
{"B":{"N":"goto","A":"oCVRS.getDrillMgr().launchGoToPage(null, true);","O":"Go To","C":"/Cognos8/rv/images/action_go_to.gif","M":{"id":"gotooCVRS","Y":"dropDown","A":"oCVRS.getDrillMgr().getDrillThroughParameters();"}}},
{"P":{"Y":"vertical_line"}},
{"B":{"N":"runIn","M":{"id":"runInoCVRS","Y":"dropDown","IS":[{"I":{"N":"viewInHTML","A":"oCVRS.getRV().viewReport(\'HTML\');","E":"View in HTML Format","C":"/Cognos8/rv/images/action_view_html.gif"}},{"I":{"N":"viewInPDF","A":"oCVRS.getRV().viewReport(\'PDF\');","E":"View in PDF Format","C":"/Cognos8/rv/images/action_view_pdf.gif"}},{"I":{"N":"viewInXML","A":"oCVRS.getRV().viewReport(\'XML\');","E":"View in XML Format","C":"/Cognos8/rv/images/action_view_xml.gif"}},{"I":{"N":"viewInExcel","E":"View in Excel Options","C":"/Cognos8/rv/images/action_view_excel_2000_single_sheet.gif","M":{"id":"viewInExceloCVRS","Y":"cascaded","IS":[{"I":{"N":"viewInspreadsheetML","A":"oCVRS.getRV().viewReport(\'spreadsheetML\');","E":"View in Excel 2007 Format","C":"/Cognos8/rv/images/action_view_excel_2007.gif"}},{"I":{"N":"viewInXLWA","A":"oCVRS.getRV().viewReport(\'XLWA\');","E":"View in Excel 2002 Format","C":"/Cognos8/rv/images/action_view_excel_2002.gif"}},{"I":{"N":"viewInSingleXLS","A":"oCVRS.getRV().viewReport(\'singleXLS\');","E":"View in Excel 2000 Single Sheet Format","C":"/Cognos8/rv/images/action_view_excel_2000_single_sheet.gif"}},{"I":{"N":"viewInXLS","A":"oCVRS.getRV().viewReport(\'XLS\');","E":"View in Excel 2000 Format","C":"/Cognos8/rv/images/action_view_excel_2000.gif"}},{"I":{"N":"viewInCSV","A":"oCVRS.getRV().viewReport(\'CSV\');","E":"View in CSV Format","C":"/Cognos8/rv/images/action_view_csv.gif"}}]}}}]}}},
{"P":{"Y":"vertical_line"}},
{"B":{"N":"openWith","M":{"id":"openWithoCVRS","Y":"dropDown","H":"true","IS":[]}}},
{"B":{"N":"home","O":"Home","C":"/Cognos8/skins/corporate/shared/images/action_home.gif","A":"oCVRS.getRV().returnHome(\"/Cognos8/cgi-bin/cognosisapi.dll?b_action=xts.run&m=portal/main.xts\");"}},
{"B":{"N":"return","O":"Return","C":"/Cognos8/skins/corporate/shared/images/action_return.gif","A":"executeBackURL(\'RS\');"}}
]});

}
else
{
oCV_NS_.rvMainWnd.setToolbar({"namespace":"_NS_","divId":"CVToolbar_NS_","style":"toolbar","S":[
{"P":{"Y":"vertical_line"}},
{"I":{"N":"logOnOff","M":{"id":"logOnOffoCV_NS_","Y":"dropDown","H":"true","IS":[{"I":{"N":"logOff","E":"Log Off","C":"/Cognos8/skins/corporate/branding/tools_logoff.gif","A":"oCV_NS_.getRV().authenticate(\"logoff\", \"/Cognos8/cgi-bin/cognosisapi.dll?b_action=xts.run&m=portal/logoff.xts\");"}}]}}},
{"P":{"Y":"vertical_line"}},
{"B":{"N":"showhide","A":"oCV_NS_.getRV().showhide();","O":"Show/HidePrompts","C":"/Cognos8/rv/cvxToolbar/ShowPrompt.jpg"}},
{"I":{"N":"keepThisVersion","E":"Keep this version","C":"/Cognos8/rv/images/action_keep_report.gif","M":{"id":"keepThisVersionoCV_NS_","Y":"dropDown","IS":[{"I":{"N":"emailReport","E":"Email Report","C":"/Cognos8/rv/images/action_send_report.gif","A":"oCV_NS_.getRV().SendReport(false);"}},
{"I":{"N":"saveReport","E":"Save Report","C":"/Cognos8/rv/images/action_save_report_output.gif","A":"oCV_NS_.getRV().SaveReport(false);"}},{"I":{"N":"saveAsReportView","E":"Save as Report View","C":"/Cognos8/rv/images/action_save_report_view.gif","A":"oCV_NS_.getRV().SaveAsReportView(false);"}}]}}},{"P":{"Y":"vertical_line"}},{"P":{"Y":"vertical_line"}},
{"B":{"N":"runReport","A":"oCV_NS_.getRV().RunReport();","O":"Run","C":"/Cognos8/rv/images/action_run.gif"}},{"P":{"Y":"vertical_line"}},{"B":{"N":"drillDown","A":"oCV_NS_.getDrillMgr().rvDrillDown();","O":"Drill Down","C":"/Cognos8/rv/images/action_drill_down.gif","D":"true"}},{"B":{"N":"drillUp","A":"oCV_NS_.getDrillMgr().rvDrillUp();","O":"Drill Up","C":"/Cognos8/rv/images/action_drill_up.gif","D":"true"}},
{"B":{"N":"goto","A":"oCV_NS_.getDrillMgr().launchGoToPage(null, true);","O":"Go To","C":"/Cognos8/rv/images/action_go_to.gif","M":{"id":"gotooCV_NS_","Y":"dropDown","A":"oCV_NS_.getDrillMgr().getDrillThroughParameters();"}}},{"P":{"Y":"vertical_line"}},{"B":{"N":"runIn","M":{"id":"runInoCV_NS_","Y":"dropDown","IS":[{"I":{"N":"viewInHTML","A":"oCV_NS_.getRV().viewReport(\'HTML\');","E":"View in HTML Format","C":"/Cognos8/rv/images/action_view_html.gif"}},
{"I":{"N":"viewInPDF","A":"oCV_NS_.getRV().viewReport(\'PDF\');","E":"View in PDF Format","C":"/Cognos8/rv/images/action_view_pdf.gif"}},{"I":{"N":"viewInXML","A":"oCV_NS_.getRV().viewReport(\'XML\');","E":"View in XML Format","C":"/Cognos8/rv/images/action_view_xml.gif"}},
{"I":{"N":"viewInExcel","E":"View in Excel Options","C":"/Cognos8/rv/images/action_view_excel_2000_single_sheet.gif","M":{"id":"viewInExceloCV_NS_","Y":"cascaded","IS":[{"I":{"N":"viewInspreadsheetML","A":"oCV_NS_.getRV().viewReport(\'spreadsheetML\');","E":"View in Excel 2007 Format","C":"/Cognos8/rv/images/action_view_excel_2007.gif"}},
{"I":{"N":"viewInXLWA","A":"oCV_NS_.getRV().viewReport(\'XLWA\');","E":"View in Excel 2002 Format","C":"/Cognos8/rv/images/action_view_excel_2002.gif"}},
{"I":{"N":"viewInSingleXLS","A":"oCV_NS_.getRV().viewReport(\'singleXLS\');","E":"View in Excel 2000 Single Sheet Format","C":"/Cognos8/rv/images/action_view_excel_2000_single_sheet.gif"}},{"I":{"N":"viewInXLS","A":"oCV_NS_.getRV().viewReport(\'XLS\');","E":"View in Excel 2000 Format","C":"/Cognos8/rv/images/action_view_excel_2000.gif"}},
{"I":{"N":"viewInCSV","A":"oCV_NS_.getRV().viewReport(\'CSV\');","E":"View in CSV Format","C":"/Cognos8/rv/images/action_view_csv.gif"}}]}}}]}}},{"I":{"N":"addThisReport","E":"Add this report","C":"/Cognos8/rv/images/action_add_report.gif","M":{"id":"addThisReportoCV_NS_","Y":"dropDown","IS":[{"I":{"N":"addToMyFolders","A":"oCV_NS_.getRV().launchNewGeneral(\"shortcut\", \"~/folder\");","E":"Add to My Folders","C":"/Cognos8/rv/images/action_add_Myfolder.gif"}},
{"I":{"N":"addToMyBookmarks","A":"oCV_NS_.getRV().addToBookmarks();","E":"Add to My Bookmarks","C":"/Cognos8/rv/images/action_add_to_bookmark.gif"}}]}}},
{"P":{"Y":"vertical_line"}},{"B":{"N":"openWith","M":{"id":"openWithoCV_NS_","Y":"dropDown","H":"true","IS":[{"I":{"N":"openWithReportStudio","A":"oCV_NS_.getRV().launchRS();","E":"Open with Report Studio","C":"/Cognos8/skins/corporate/branding/tools_report_studio.gif"}}]}}}]});

}

</script>
<script language="javascript">
function showhide()
{
if(document.getElementById("list1").style.display=="none")
{
document.getElementById("list1").style.display="";

}
else
{
document.getElementById("list1").style.display="none";
}
}
</script>

</HTML>
Title: Re: Cognos 8.4: Javascript working from Report studio but not from Namespace
Post by: venkiatmaruthi on 03 Mar 2011 07:04:28 AM
Hi,

Another observation I found is it is not coming for first time. If you rerun it again then it works fine.
Not getting any clue why is it behaving. For few reports it's working fine and for few this script is not working... why is it so?

really appreciate your help.
Title: Re: Cognos 8.4: Javascript working from Report studio but not from Namespace
Post by: venkiatmaruthi on 04 Mar 2011 06:38:26 AM
No body there to help me. atleast give a kind of suggesion/Idea why it's working like that?
Title: Re: Cognos 8.4: Javascript working from Report studio but not from Namespace
Post by: Shailaja0520 on 04 Mar 2011 08:31:40 AM
Just a clue   don't know if it helps you or not...

I had the same problem but with other tabs .Presently i am unable to test your code as i don't have the environment..

I created the variable to dynamically store the Rs and Ns value and used that.

var cvid = getFormWarpRequest().elements["cv.id"].value;
var sid =  "oCV" + cvid;

Showhide function can be called on the onclick of the list item.
for e.g.
onclick="javascript:showhide()"

And dynamically use the variable  like this

onclick="window[sid].getRV().SendReport(false);"





Title: Re: Cognos 8.4: Javascript working from Report studio but not from Namespace
Post by: venkiatmaruthi on 07 Mar 2011 11:23:39 PM
Thanks Suhan.

However the problem is not with RS or NS. The problem is the default toolbar overwriting the custom toolbar for first time. If you rerun or go back and run again, the
show/hide button works.

Title: Re: Cognos 8.4: Javascript working from Report studio but not from Namespace
Post by: Shailaja0520 on 08 Mar 2011 03:33:57 AM
ok..Forgot to see you attached screenshot...

if the default toolbar is overriding the custom one the why dont you hide that
Did you hide the default header before creating the custom one

<style>

  .mainViewerHeader3
  {
       display: none;
  }
</style>
 
and

<style>

  .mainViewerHeader2
  {
       display: none;
  }
</style>
Title: Re: Cognos 8.4: Javascript working from Report studio but not from Namespace
Post by: venkiatmaruthi on 10 Mar 2011 07:45:40 AM
Thanks Suhan.

Actually here, what we are doing is_

We are not exactly creating a custom toolbar rather modifing/adding extra icons to the default toolbar.
For the default toolbar, we are adding neccessary icons what customer want like show/hide button.
Title: Re: Cognos 8.4: Javascript working from Report studio but not from Namespace
Post by: Shailaja0520 on 10 Mar 2011 10:28:57 AM
I think the alternative way would be creating a complete custom toolbar and hiding the complete row of the default one.No Problems after that.

or you may have to  try moving  the extra icons  so it doesn't get overridden,takes its own space.