- IBM Cognos 8 Report Studio Cookbook
- Abhishek Sanghani
- 307字
- 2021-08-06 17:15:50
Changing title of the dropdown box
In the previous example, the first line of value prompt shows the data item name, that is, Month key (Shipment date).

The business wants to change this to a more generic and user-friendly text.
Getting ready
We will use the report generated in the previous recipe.
How to do it...
- We need to add a line to the JavaScript from the previous recipe to change the text of first option (index 0). For that, open the prompt page of the report created in the previous recipe.
- Double-click on the HTML item in the prompt footer.
- Replace the code with the following:
<script> var theSpan = document.getElementById("A1"); var a = theSpan.getElementsByTagName("select"); for( var i = a.length-1; i >= 0; i-- ) { var prompts = a[i]; if( prompts.id.match(/PRMT_SV_/)) { prompts.selectedIndex = 3; prompts.options[0].text = 'Choose Shipment Month'; /* This is the new line added to script */ } canSubmitPrompt(); } </script>
- Run the report to test it.

How it works...
By default, the first line of a value prompt is the name of the data item.If you define the data item expression within brackets, that is, ([Sales (query)].[Time (ship date)].[Month key (ship date)])
in this example, then the first line of value prompt is populated by the parameter name.
However, there is no property within Report Studio that would allow us to put a custom title. Hence, we are using JavaScript. We already know how to capture the prompt control using GetElementsbyTagName
function. Once it is captured, we can manipulate the values. We change the text property of options[0]
element to update the first line of prompt.
There's more...
You can also use the REMOVE()
function to remove particular lines of a value prompt. It is often useful to remove the first two lines (title and separator) using the following statements:
Prompts.remove(0); Prompts.remove(1); Prompts.removeAttribute("hasLabel");
- 現代企業應用設計指南
- 中文版Photoshop入門與提高(CS6版)
- 四時風月繪:國風水墨CG插畫繪畫技法
- 從零開始:Flash CS6中文版基礎培訓教程
- 數字孿生體:第四次工業革命的通用目的技術
- 3ds Max/MaxScript印象 腳本動畫制作基礎與應用
- Illustrator 2024從入門到精通
- Adobe創意大學Illustrator CS5 產品專家認證標準教材
- SOA Patterns with BizTalk Server 2009
- 中文版Maya 2016實用教程
- SolidWorks 2020中文版從入門到精通
- Microsoft SharePoint 2010 and Windows PowerShell 2.0: Expert Cookbook
- Oracle BI Publisher 11g: A Practical Guide to Enterprise Reporting
- 3ds Max三維動畫制作項目式教程
- 3ds max 2018中文版基礎與實例教程(第6版)