2015-05-28 27 views
0

在我的Cognos報告中,我嘗試了兩種選擇。一旦選擇「通過NDC11選擇」單選按鈕,我應該能夠從列表框中選擇值,並且當選擇「通過NDC11文本框選擇」單選按鈕時,我應該取消選中上述單選按鈕選項並且能夠進入下面的文本框中的值。Cognos 10中的單選按鈕組選擇

如果選擇了另一個,我無法做到取消選中單選按鈕組的功能。

回答

0

假設您正在使用Cognos BI版本10.2或更高版本,則可以使用Cognos JavaScript API來執行所需操作。

爲了操縱使用JavaScript API的提示,您必須爲每個提示提供一個唯一的名稱。在這個例子中,它們將被命名爲test1和test2。當test2被選擇時,test1提示符將成爲你想取消選擇的提示符。

在您的提示頁面的底部添加一個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提示符都將被清除。