Generally the select box of the Select and Search prompt is wide enough to display all the information you need. But there are times where you need it to show everything.
Is the first option there Chaun Yang Sport Equipment Company? Org? IBM does have a way to fix this issue, but it involves modifying one of the internals, specifically the webcontentpromptingproperties.js file. In several of my clients, modifying any internal files is expressly forbidden. So I’ve written a quick and somewhat dirty javascript to handle it.
Drag an HTML item to the left of the prompt:
<div id="selectSearch">
Drag an HTML item to the right of the prompt:
</div> <script> var e=document.getElementById('selectSearch'); var myselect = e.getElementsByTagName('select')[0]; if(myselect.childNodes.length>0){myselect.style.width=''} </script>
This code will find the selectSearch div you wrapped the prompt with, find all of the select tags, and if there are any options the select will expand or shrink to fit.
And finally, as usual (when I remember) the report XML:
<report xmlns="http://developer.cognos.com/schemas/report/8.0/" useStyleVersion="10" expressionLocale="en-us"> <modelPath>/content/folder[@name='Samples']/folder[@name='Models']/package[@name='GO Data Warehouse (query)']/model[@name='model']</modelPath> <drillBehavior modelBasedDrillThru="true"/> <layouts> <layout> <reportPages> <page name="Page1"> <style> <defaultStyles> <defaultStyle refStyle="pg"/> </defaultStyles> </style> <pageBody> <style> <defaultStyles> <defaultStyle refStyle="pb"/> </defaultStyles> </style> <contents><HTMLItem> <dataSource> <staticValue><div id="selectSearch"></staticValue> </dataSource> </HTMLItem><selectWithSearch parameter="Parameter1" refQuery="Query1"><useItem refDataItem="Retailer"/></selectWithSearch><HTMLItem> <dataSource> <staticValue></div> <script> var e=document.getElementById('selectSearch'); var myselect = e.getElementsByTagName('select')[0]; if(myselect.childNodes.length>0){myselect.style.width=''} </script></staticValue> </dataSource> </HTMLItem></contents> </pageBody> </page> </reportPages> </layout> </layouts> <XMLAttributes><XMLAttribute name="RS_CreateExtendedDataItems" value="false" output="no"/><XMLAttribute name="listSeparator" value="," output="no"/><XMLAttribute name="RS_modelModificationTime" value="2011-06-09T13:50:33.233Z" output="no"/></XMLAttributes><queries><query name="Query1"><source><model/></source><selection><dataItem name="Retailer" aggregate="none"><expression>[Sales (query)].[Retailers].[Retailer]</expression></dataItem></selection></query></queries></report>
The XML is for Cognos 10, but this code was tested successfully on all the flavors of Cognos 8.4.
Nice… im glad i subscribed. have t try this…Ty 🙂
Hi,
Can plz post the java script for changing the default options in the Prompt.
Thanks
Ravi
Hi Ravi,
I am looking for the same thing . Have you got the solution for this.?
Hi,
Can you plz post the java script for changing the default options in the Prompt??
thats very helpful to me.
Thanks
Ravi
I was able to modify my prompt page using this – appreciate it very much!
I have two search and select prompts on the same page and am trying to size both. The first one is working, but the second isn’t re-sizing. Is there any trick to this? Also, is there a similar script to resize a value prompt list box? Thanks!
Hi Elizabeth,
All that needs to be done is to increment the ID in the div and the getElementById by 1 for each select and search.
Hi,
Is there a way to set the the width of a value prompt (drop down) to a certain value. Then once you click on the drop down the results shown (parameters) are wider than the initial default width of the prompt.
Thanks!
Is there a way to pre-populate the choice box with all values? And have the keyword / search be used just to refine the list?
Hi We need to change default option of Select and Search prompt from Starts with any of these keyword to Contains any of these keywords. Above given code is not working. We are using Cognos 8.4.1. Can you please provide the XML of the sample example. Thank you Very much in advance.
I tried the above source code given. But i am getting the error. Error given below.
The report version “http://developer.cognos.com/schemas/report/8.0/” is not supported.
Expected report version “http://developer.cognos.com/schemas/report/6.0/”.
Making Select and Search Prompt Dynamically Re-size
1.Locate and backup the file ..\c8\webcontent\prompting\properties.jslocated within an install of the IBM Cognos 8 gateway component.
2.Set the SYSTEMPROPERTY_CSEARCH_AUTO_RESIZE_RESULT_LISTto true.
———————————————————————–
// Copyright (C) 2008 Cognos ULC, an IBM Company. All rightsreserved.
// Cognos (R) is a trademark of Cognos ULC, (formerly CognosIncorporated).
/* Use this file to override flags in the prompt controls. */
/*
Use the following flag to disable search request when theuser press Enter in the search input box.
This is a workaround to prevent searches when users usejapanese IME input control.
*/
var Search_DisableEnterKeyAutoSubmit = false;
var SYSTEMPROPERTY_CSEARCH_AUTO_RESIZE_RESULT_LIST = true;
var SYSTEMPROPERTY_CREATE_CUSTOM_SCRIPTS_REFS = true;
var SYSTEMPROPERTY_CUSTOM_SCRIPTS_OVERRIDE_FORM_SUBMIT = false;
var SYSTEMPROPERTY_REORDER_DROPDOWN_VALUES_IN_RANGES = false;
————————————————————————–
Refer : http://public.dhe.ibm.com/software/dw/dm/cognos/reporting/prompts_and_filters/auto-size_select_and_search_prompt.pdf
Hey!
I see this question has been asked Before but my problem is that im using 2 select and search prompt on my main page. They are both optional and when i run the report it starts with showing those to prompts, as generic prompts. I can just click finish to go to the report but I want to come directly to the report.
I’ve been trying to use the #prompt macro but I havent gotten it to work.
Any help or suggestion would be greatly appreciated!!
/Peter
In general Cognos will create those generic prompts on a generated prompt page if there are any parameters that don’t have matching prompts. So if the report has a prompt with the same parameter name on the page, it should go directly to the report. Are there any variables to hide the prompts? Can you doublecheck that each parameter in the report has a matching prompt?
Hi
I found out what was wrong. I used a conditional block that switched pane depending on a value prompt. The panes conatined the select and search prompts. It seems that when using a conditional block the default value does not work. When i moved the select and search prompts outside the conditional block it worked.
Thanks for the tips though! Helped me focus on the right part.
Hi
I dont use a prompt page, and I dont want to. The problem is that its hard to set a default value for a select and search prompt. And even though its optional it still creates those generic prompts.
The two select and search prompts are in a conditional block that switches based on a variable from a value prompt. Does that affect it?
Yeah each parameter has a matching prompt!