ReportServer has no concept of optional/required parameters, sll parameters must always have a value.
But depending on the parameter type parameters may appear as optional to the user because
* the default value is used
* an empty value is accepted
With a data driven parameter add an EMPTY value and make it the default to make the parameter optional. Without the explicitly empty value the user has to make a selection in order to not use the wrong value, so the parameter is mandatory.
With a text parameter you can specify a pattern (as a regular expression) the value must match. If you disallow empty values the parameter is required, otherwise it’s optional.
I understand the concept of data driven parameter. I believe it can work most of the time. What can cause problems for our users are dates. For example, imagine we have 2 date paremeters: startDate and endDate. We need to make sure that the endDate is greater than the startDate. I will discuss this with my team. But thanks for explaning.
Another question about the parameters: Is there any way I can create text parameters (not DataSource parameters) as radion buttons?
unfortunately there is no validator that checks a parameter with respect to other parameters. If this is essential you could take a look at the script parameters. This allows you to use javascript to render your parameter and you could then implement a custom date-range component that performs these checks.
Checkboxes/Radio Buttons only work in conjunction with the datasource parameter. But you could create a CSV-Datasource with the “Argument Connector”. If you do this and use the datasource with your parameters you can than specify the parameter values as csv in the parameter configuration.
We are still in the process of updating the documentation to include all the changes introduced with RS 2.2.
So it’s not in there, yet, but it will be with the release of 2.2.
I can give you a small example of a simple script parameter
#html
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="../resources/js/leaflet/leaflet.css" type="text/css" />
<link rel="stylesheet" href="../resources/js/leaflet/leaflet.draw.css" />
<script src="../resources/js/leaflet/leaflet.js" type="text/javascript"></script>
<script src="../resources/js/leaflet/leaflet.draw.js" type="text/javascript"></script>
</head>
<body screen_capture_injected="true">
<div id="map" style="width: 600px; height: 400px;" ></div>
<script type="text/javascript">
var callback;
function initParameter(param, cb){
callback = cb;
}
var map = L.map('map').setView([50.0600, 8.3110], 11);
var tiles = 'https://{s}.tiles.mapbox.com/v3/{id}/{z}/{x}/{y}.png';
L.tileLayer(tiles, {
maxZoom: 18,
attribution: '',
id: 'examples.map-20v6611k'
}).addTo(map);
var drawnItems = new L.FeatureGroup();
map.addLayer(drawnItems);
var drawControl = new L.Control.Draw({
draw: {
position: 'topleft',
polygon: false,
polyline: false,
circle: false,
marker: false
},
edit: false
});
map.addControl(drawControl);
map.on('draw:drawstart', function(e){
drawnItems.clearLayers();
});
map.on('draw:created', function (e) {
var type = e.layerType,
layer = e.layer;
var bounds = layer.getBounds();
var res = (bounds.getSouthWest().lng + " " + bounds.getSouthWest().lat + ", " + bounds.getNorthEast().lng + " " + bounds.getNorthEast().lat);
callback(res);
drawnItems.addLayer(layer);
});
</script>
</body>
</html>
This example renders a map from openstreetmap and allows the user to select coordinates by drawing a rectangle.
the #html marks the script as to be returned as-is without looking for groovy code
the initParameter(param, cb) function is called by when the parameter is added to the view. To register a new parameter value with ReportServer your code has to call the passed callback.
If you upload this script into the fileserver/bin directory you can select it from a script parameter in your report.
This uses leaflet.js (http://leafletjs.com/) so to actually test the code you have to download the required libraries and add them to the appropriate directory.