7.3.6. The Datasource Parameter

The datasource parameter provides you with the option to enable the user to choose from a selection of pre-set values. The specified values will be provided by a datasource, giving it its name. ReportServer expects a table with one or two columns to be returned from the datasource. Here, if there is one column the values will be taken as display value and parameter value. If two columns are returned, by default the first column is regarded as parameter value and the second one as display value. If you configured a datasource with the following contents:

1 A
2 B
3 C
4 D

the user will be displayed "A,B,C,D". When selecting A the value would be passed on as a parameter value.

Directly Entering the Value List

In some cases you may wish to enter the parameter values directly at the parameter without a detour via the database. Here, the solution is a CSV datasource with an argument connector (refer to ''datasources''). This enables you to enter the values for the parameter directly at the parameter. When generating the datasource please observe to deactivate the database cache. Please consider as well that the first line of the CSV data hold the description of the data. To enter the above data as CSV table proceed as follows

VALUE;DISPLAY
1;A
2;B
3;C
4;D
Subsequent Processing of Values

By using post-processing you can make complex changes to parameter data. Please note that post-processing needs to be activated in the configuration (see ReportServer configuration guide). Here you may give a Groovy script which will run for each data line. The current line will be given to the script as data. To change the place of VALUE and DISPLAY you can use the following simple script:

data.reverse()

ReportServer expects a list or an array to be returned. To exclude values you can return NULL. Instead of returning a single value you can also return multiple values by means of a nested list. If you return

[[1,'A'],[2,'B']]

this would, for instance, result in adding two data records.To better control the output, beside the replacement data, the replacement cnt (an integer value) will be provided. isLast here indicates whether the value currently processed is the last value. cnt counts the number of data records processed beginning with 0.

Please consider that ReportServer will for consistency reasons ensure that there will be no duplicates in the return. This means that when the data hold exactly the same value twice, only one will be presented to the user for selection.

Security

Allowing users to execute Groovy bears a security risk. Thus, you should be careful when enabiling this option, since this means that any user that is able to edit reports can potentially execute arbitrary code.

Selection Mode

You can determine via the selection mode whether the user can select multiple values or only one. Depending on the setting chosen, there are various views available to you. For multiple selection options you can choose from the usual selection dialogue (pop up) and check boxes. The height and width settings control the display of the selected values when selected from the dialogue. When opting for the check boxes you can control the ranging of the check boxes via the settings layout, packing mode and number per. Here the layout option controls the basic orientation, i.e. whether the values will be entered first from top to bottom or from left to right. The "packing mode" setting controls whether you rather want to opt for the number of columns or the number of packages. Then with the number per option you control this number. The best way to explain this is by giving you an example. Let us assume we can choose from 11 values. If we now select Column as packing mode and as number, the values will be arranged in two columns where the first one will hold 6 values and the second one 5 values (with the layout setting top/bottom, left/right).

A G
B H
C I
D J
E K
F  

However, if you choose package as the packing mode, ReportServer will arrange columns of size . Consequently, the objects would be arranged as follows:

A C E G I K
B D F H J  

For the single selection setting you can draw from selection list (drop down), selection dialogue (pop up), or radio buttons. If you take the last option, the layout will be controlled in the same way as with multiple choice check boxes.

Typing

By typecasting you control the type of objects that ReportServer will attempt to return. Of course, this must be based on the data available. If a value is to be returned as a date, you can specify the available date format by the setting format. The syntax to be used here is explained under:

http://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html

Default Values

By using the option default values you can determine the values selected by default. Please consider here that for a single selection from a selection list (drop down) the convention applies that if there is no determined default value, normally the first value will be selected.