There is a report where users can select multiple product lines from a listbox. When they rerun the report, the previous selection is remembered.
Users want the selection to be automatically cleared on re-run.
Getting ready
Select any existing report or create a new sample report that filters on ProductLines. Create a Listbox type of prompt for the product line. Set its multi-select property to Yes.
How to do it...
Wrap the listbox in a span similar to previous recipes; that is, create two HTML items around the listbox and define span A1.
Now define a new HTML item in prompt page footer as follows:
<script>
var theSpan = document.getElementById("A1");
var a = theSpan.getElementsByTagName("A");
for( var i = a.length-1; i >= 0; i-- )
{ var link = a[i];
if( typeof(link.id) == "string" && link.id.match(/PRMT_(SV|LIST)_LINK_DESELECT_/) )
{link.fireEvent("onclick");}
}
</script>
Run the report for any product line. Then re-run the report by clicking the Run button. Notice that the previous prompt selection is cleared.
How it works...
With a multi-select listbox control, Report studio throws in two links on the prompt page. These are for SELECTALL and DESELECTALL functionalities.
Here we are capturing the Deselectall link and then calling it by fireevent() function.
There's more...
You can optionally check for PRMT_(SV|LIST)_LIST_SELECT in the Id and call the SelectAll link when appropriate.
Also, you can use the following line in script if you want to remove a link from the page at run time: