【问题标题】:Radio Button Group Selection in Cognos 10Cognos 10 中的单选按钮组选择
【发布时间】:2015-05-28 15:25:10
【问题描述】:
在我的 cognos 报告中,我试图有两个选择。 Once a "Select by NDC11" radio button is selected I should be able to select the values from the list box, and when the "Select by NDC11 Textbox" radio button is selected, I should uncheck the above radio button selection and able to enter下面文本框中的值。
如果选择了另一个,我无法执行取消选中单选按钮组的功能。
【问题讨论】:
标签:
radio-button
unchecked
cognos-10
cognos-bi
【解决方案1】:
假设您使用的是 Cognos BI 10.2 或更高版本,您可以使用 Cognos JavaScript API 来做您想做的事情。
为了使用 JavaScript API 操作提示,您必须为每个提示指定一个唯一的名称。在本例中,它们将被命名为 test1 和 test2。 test1 提示将是您在选择 test2 时要取消选择的提示。
在提示页面底部添加一个 HTML 项并插入以下代码:
<script>
var report = cognos.Report.getReport('_THIS_'); //Assign a variable to the report object
var test1 = report.prompt.getControlByName('test1'); //Assign a variable which points to the first prompt object
var test2 = report.prompt.getControlByName('test2'); //Assign a variable which points to the second prompt object
test2.setValidator(validateTest2); //Call the API's setValidator function to assign a function to fire on prompt change
function validateTest2(values) {
if (values && values.length > 0) { //Check if test2 has a value selected
test1.clearValues(); //Call the API's clearValues() function on test1 which deselects all values
}
return true; //Successfully validate prompt
}
</script>
由于我们提供自定义验证功能,您可能需要根据是否将提示设置为必需等来调整返回值。
使用此脚本,任何时候在 test2 提示符中选择一个值,都会清除 test1 提示符。