Support

Lorem ipsum dolor sit amet:

24h / 365days

We offer support for our customers

Mon - Fri 8:00am - 5:00pm (GMT +1)

Get in touch

Cybersteel Inc.
376-293 City Road, Suite 600
San Francisco, CA 94102

Have any questions?
+44 1234 567 890

Drop us a line
info@yourdomain.com

About us

Lorem ipsum dolor sit amet, consectetuer adipiscing elit.

Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec.

In this post, we would like to show you an example of how to add a javascript color picker as a report parameter, which can be then used as any other parameter in your SQL queries. This is the basis for further scripts we are posting here soon, so stay tuned!

We create a script parameter (https://reportserver.net/en/guides/admin/chapters/parameter-script/), since a script parameter allows you to write custom HTML and javascript.

For this purpose, download the latest jscolor javascript file from here: http://jscolor.com/. At the time of writing, the latest version was 2.0.5. Copy the downloaded jscolor.js file into this location: Fileserver Root/lib/jscolor/jscolor.js. Check in the ”Properties” tab the URL of this file in your installation. It should be something similar to: http://localhost:8080/reportserver/reportserver/fileServerAccess?id=2189950.

Now you can create the script which will be the basis of your script parameter. We name this script PalettePicker.groovy:

#html <html> <head> <script type="text/javascript" src="http://localhost:8080/reportserver/reportserver/fileServerAccess?id=2189950"></script> <script type="text/javascript"> var callback; function initParameter(param, cb){ callback = cb; //alert("The current value is: " + param.defaultValue); document.getElementById("mycolor").value = param.defaultValue; document.getElementById("mycolor").style.backgroundColor = '#' + param.defaultValue; setValue(param.defaultValue); } function setValue(value){ //alert("Updating the value to: " + value); callback(value); } </script> </head> <body> <input id="mycolor" class="jscolor" onchange="setValue(this.value);"> </body> </html>
As you can see in the script, you install a color picker and use the default value for setting the initial value and background color of the input field. The URL mentioned previously must be adapted to your configuration:
<script type="text/javascript" src="http://localhost:8080/reportserver/reportserver/fileServerAccess?id=2189950"></script>
Finally, you can create the script parameter in your report and set the script field to point to your PalettePicker.groovy script in your parameter’s ”Specific Properties” dialog. Set your parameter’s default value to e.g.: ”FF0000” (without apostrophes). You can now use the color picker’s value in your query as:
SELECT * FROM myTable where myField = $

Note that your parameter’s name must be set to ”mycolor” for using this query.

This approach works for virtually all javascript libraries. Script arguments are a powerful tool for extending ReportServer parameters to user-defined functionality.

Many thanks to Karolina Boboli for sending us this and allowing us to publish the script.

Zurück

InfoFabrik GmbH

Wir wollen, dass alle Unternehmen, Institutionen und Organisationen, die Daten auswerten, selbständig und zeitnah genau die Informationen erhalten, die sie für ein erfolgreiches Arbeiten benötigen.

InfoFabrik GmbH
Klingholzstr. 7
65189 Wiesbaden
Germany

+49 (0) 611 580 66 25

Kontaktieren Sie uns

Bitte rechnen Sie 1 plus 7.
Copyright 2007 - 2024 InfoFabrik GmbH. All Rights Reserved.

Auf unserer Website setzen wir Cookies und andere Technologien ein. Während einige davon essenziell sind, dienen andere dazu, die Website zu verbessern und den Erfolg unserer Kampagnen zu bewerten. Bei der Nutzung unserer Website werden Daten verarbeitet, um Anzeigen und Inhalte zu messen. Weitere Informationen dazu finden Sie in unserer Datenschutzerklärung. Sie haben jederzeit die Möglichkeit, Ihre Einstellungen anzupassen oder zu widerrufen.

Datenschutzerklärung Impressum
You are using an outdated browser. The website may not be displayed correctly. Close