## Parameter fields

A parameter in JReport is a variable whose value is determined at runtime. The runtime parameters help you dynamically control your report results.

### Inserting a parameter field in a report

Parameter fields can be inserted in the report areas listed in Component placement. Before you can insert a parameter field into a report, you need to create it. For details about how to create parameters, see Creating a parameter.

To insert a parameter field into a report, you can use either of the following methods:

- Using dialog
  1. Position the mouse pointer at the destination where you want to insert the parameter and do one of the following:
     - Click Insert > Parameter on the menu bar.
     - Click the Insert Parameter button on the Insert toolbar.

     The Insert Fields dialog appears. See the dialog.

  2. Select the required parameter from the Parameters node, then specify its layout in the Insert Layout box.
  3. Click the Insert button to insert the parameter into the destination.
- By dragging and dropping

  Select the required parameter from the Resource View panel, then drag it to the destination.

When a parameter field has been inserted into a report, you can customize its appearance and behavior by setting properties in the Report Inspector, which can be saved as a CSS style for future use (for details, see Creating a CSS style).

Notes:

- No matter which way you take, if the given parameters are not what your want, click the <Add Parameter...> item to create one as required.
- If you insert a parameter into the detail panel of a banded object or table, the name of the parameter will automatically be inserted as a label into the corresponding header panel. Otherwise the parameter and its name label will be placed in the same panel. If you do not want to insert the name label automatically, you can go to the Options dialog, select Component in the Category box and then uncheck the Insert field name label with field option.

### Changing the display type of a parameter field

The display type of a parameter field can be changed according to your requirements, that is to say, you can map the parameter field to another value or image to be displayed instead.

To change the display type a parameter field:

1. Right-click the parameter field and select Display Type from the shortcut menu.
2. In the Display Type dialog, specify the required display type in the Display As box, and set the options for the selected type as required.
   - To change the display type of a parameter to list or drop-down list, select the item List or Drop-down List, and then in the Web Options panel, set the name and title. You may notice that a default list item had been added, and its value is the parameter. If you check Use Runtime Value, when running the report, you need to specify a value for the parameter, and then the item same as the value will be selected in the list or drop-down list by default; if you uncheck the option, the Selected text box will be enabled for you to input a value and the item same as this value will be selected. For the List type, you can check Allow Multiple Selections to enable more than one item selected.
   - For other display types, refer to Changing the display type of a label for details.
3. Upon finishing, click the OK button to close the dialog.

### Binding a link to a parameter field

You can make a parameter field linked with another report, a URL or an e-mail. To do this:

1. Right-click the parameter field and select Detail Report on the shortcut menu to display the Master/Detail Report dialog.
2. From the Link to drop-down list, specify the target to which the parameter field will be linked.
3. Set the options for the target according to your requirements.
4. When done, click OK.

For details about different link targets, see Binding a link to a label.

### Adding conditional formats to a parameter field

You can add some conditional formats to a parameter field, then when the specified condition is fulfilled, the defined format will be applied to the field values for distinguishing.

To add conditional formats to a parameter field:

1. Right-click the parameter field and select Conditional Formatting from the shortcut menu.
2. In the Conditional Formatting dialog, click the button to add a condition as required.
3. Set the format that will be applied to the field values when the specified condition is fulfilled.
4. Repeat the above two steps to add more conditions and define the format for each condition as required.
5. When done, click OK to save the settings.

For more details about conditional formatting, see Adding conditional formats to a DBField.

See an example: The SampleComponents catalog, included with JReport Designer, contains reports that have examples of how each component type could be used in a report. For the parameter field examples, open the following report set: `<install_root>\Demo\Reports\SampleComponents\Parameter.cls`, and `<install_root>\Demo\Reports\SampleComponents\ParameterField.cls`.