COGNOS下拉框(值提示)设置默认值

------需求:

第一次打开报表就自动输入默认值。

------解决方案:
在report studio内增加以下javascript.

<script type="text/javascript">

var theSpan = document.getElementById("A1");
var theSelect = theSpan.getElementsByTagName("select");
theSelect[0].options[2].selected=true; //这行可以使默认值成为下拉列表虚线下的第一个值
theSelect[0].options[0].text = '<可以在这里给下拉列表取名字>';

canSubmitPrompt();

</script>

[@more@]

------详细方案英文原版:

Title:
Javascript: Changing first line and set default selection in value prompt for 8.3

Document#:
1038662.3

Updated:
Dec 01, 2008

Applies To: 
Cognos 8 BI Report Studio 8.3 


SRs: 



Collection: 
KB 



--------------------------------------------------------------------------------


Note: This technique uses JavaScript against underlying report objects and methods in a IBM Cognos 8 BI report. For this reason, there is no guarantee that reports created using this technique will migrate or upgrade successfully to future versions without requiring modifications. Any such modifications are the responsibility of the report designer.

Description:

The following is a sample Javascript that allows for the first item in a value prompt to be selected and the descriptive text of the value prompt to be renamed in Cognos 8.3.

Environment:

C8.3 Report Studio 

Root Cause:

Prompt objects in Cognos 8.3 are now dynamically named. This is why methods such as:

document.formWarpRequest._oLstChoicesprompt1[0].text = 'Select a Order Method...';

document.formWarpRequest._oLstChoicesprompt1.options[0].selected = true;

may no longer work because of the way in referencing the objects. The solution below is one way to access the objects.

Solution:

Surround the value prompt with HTML items in Report Studio, then add a third HTML item at the bottom of the prompt page with new script

Steps:

1. Add an HTML item to the left and right of the value prompt in the Report Studio

2. For the first HTML item (left) add '<span id = "A1">'

3. For the second HTML item (right) add '</span>'

4. Add an HTML item at the bottom of the prompt page next to "Run" button

5. Add the following script for the third HTML item:

<script type="text/javascript">

var theSpan = document.getElementById("A1");
var theSelect = theSpan.getElementsByTagName("select");
theSelect[0].options[2].selected=true; //This will make default value in prompt to be the first item after line, change the value '2' for other item
theSelect[0].options[0].text = '<PUT WHATEVER TEXT FOR VALUE PROMPT TITLE HERE>';

canSubmitPrompt();

</script>

6. The value "A1" can be anything you like. Run the Report. This works well when using prompt page.

7. Add the following script if you don't want to use a prompt page, and want to use auto-submit in the value prompt within the same page as the list/crosstab. In this case the third HTML item is put after the second HTML item that contained the close span. The first two HTML item will still need to be in the left and right of the value prompt object. The script looks like:

<script type="text/javascript">

function init()
{

var theSpan = document.getElementById("A1");
var theSelect = theSpan.getElementsByTagName("select");
theSelect[0].options[2].selected=true; //This will make default value in prompt to be the first item after line, change the value '2' for other item
theSelect[0].options[0].text = '<PUT WHATEVER TEXT FOR VALUE PROMPT TITLE HERE>';
promptButtonFinish();
}

</script>
<body onLoad=init()>

Related documents:

The following knowledge base articles describe additional methods of modifying the formWarpRequest to access the same objects in Cognos 8.3.

1013968 - Javascript: Changing the First Line of a Value Prompt or DropDownList prompt.

1036117 - JavaScript: Sample to automatically select first item in value prompt

Upgrading Javascript Applications to IBM Cognos 8.3/8.4 
http://support.cognos.com/en/support/diagnostics/pdf/upgrading_javascript_applications.pdf

Keywords:

8.3 Script Value Prompt Title Default Selection Java

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值