DBFields
DBFields, or database fields, are fields directly from databases, user data sources, hierarchical data sources, or other data sources.
Inserting a DBField in a report
DBFields can be inserted in the report areas listed in Component placement.
To insert a DBField into a report, you can use either of the following two ways:
When a DBField 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:
- To insert more than one DBField with the Insert Field dialog, you can select them one by one with the Ctrl key, or you can make a continuous selection with the Shift key.
- You cannot use the Insert Fields dialog to insert a DBField into a crosstab.
- If you insert a DBField into the detail panel of a banded object or table, the name of the DBField will automatically be inserted as a label into the corresponding header panel. Otherwise the field and its name label will be placed in the same panel. If you do not want to insert the field name automatically, you can uncheck Insert field name label with field in the Options dialog (File > Options > Component > Insert field name label with field).
Adding a summary for a DBField
To add a summary for a DBField:
- Right-click the DBField and select Summary Function from the shortcut menu.
- In the Insert Summary dialog, specify the summary settings as required.
- When done, click Insert.
For more information, see Inserting a summary in a report.
Changing the display type of a DBField
The display type of a DBField can be changed, that is to say, you can map the DBField to another value or image to be displayed instead.
To change the display type a DBField:
- Right-click the DBField and select Display Type from the shortcut menu.
- In the Display Type dialog, specify the required display type in the Type box, and set the options for the selected type in the Web Options panel.
- Upon finishing, click the OK button to close the dialog.
For details about display types, see Changing the display type of a label.
Applying web actions to a DBField
A DBField can be bound with some web actions. This allows you to customize a DBField to make it respond to some events, and execute corresponding actions, such as sorting and filtering.
To apply web actions to a DBField:
- Right-click the DBField and select Display Type from the shortcut menu.
- In the Web Behaviors box of the Display Type dialog, choose an event from the Events column, then click in the Actions column and click that appears in the text box.
- In the Web Action List dialog, select a web action and define the action as required.
- Click in the Display Type dialog to add more web behavior lines and specify the events and actions accordingly. If a web behavior is not required, click to remove it.
- Adjust the order of the added web actions by clicking or . Then, when an event that has been bound with more than one action happens, the upper action will be triggered first.
- When done , click OK to accept the settings.
For more information about web actions, see Applying web actions to a label.
Binding a link to a DBField
You can make a DBField linked with another report, a location specified by a URL, an e-mail address, or a Blob data type field. The link can either be a simple link or a conditional link. With conditional link, different targets can be loaded based on different conditions.
To bind a link to a DBField:
- Right-click the DBField and click Link on the shortcut menu.
- In the Insert Link dialog, specify whether it is a conditional link or a simple link, then select the link target and set the options for the link target as required.
- When done, click OK.
For details about different link targets, see Binding a link to a label.
Adding conditional formats to a DBField
You can add some conditional formats to a DBField, then when a specified condition is fulfilled, the format bound with the condition will be applied to the field values automatically for distinguishing.
To add conditional formats to a DBField:
- Select the DBField and then do one of the following:
- Click Format > Conditional Formatting on the menu bar.
- Click the Conditional Formatting button on the Format toolbar.
- Right-click the DBField and select Conditional Formatting from the shortcut menu.
The Conditional Formatting dialog appears. See the dialog.
- Click above the Condition box. The Edit Conditions dialog appears. See the dialog.
- Click the Add Condition button to add a condition line.
- From the field drop-down list, select the field on which the condition will be based.
- Choose the operator with which to compose the condition expression from the operator drop-down list.
- From the value drop-down list, specify the value of how to build the condition. You can also type in the value manually.
- Click Add Condition to add more condition lines and define the relationship between the condition lines.
- When done, click OK to save the condition. The newly added condition will then be displayed and highlighted in the Condition box in the Conditional Formatting dialog.
- In the Format box, set the format which will be applied to values of the DBField when the specified condition is fulfilled, such as the font face, font size, font color and so on.
- Repeat the above steps to add more conditions and define the format for each condition.
To edit a condition, select the condition from the Condition box, click , then edit the condition in the Edit Conditions dialog.
To adjust the priority of the conditions, select a condition and click the High or Low button.
To remove a condition and the corresponding format, select the condition from the Condition box and then click .
- When done, click OK to save the settings.
Searching for a specific DBField in a report
When a report has many DBFields, you may find it difficult to locate where a certain field is. To easily find out the field you have lost track of in your report, you can make use of the Find DBField feature.
To find a DBField in a report:
- Click Edit > Find DBField on the menu bar, or the Find DBField button on the Standard toolbar. The Find dialog appears. See the dialog.
- Select the field you want to locate from the Find What drop-down list.
Tip: Besides DBFields, formula fields used in the report will also be listed in the Find What drop-down list, so you can also use this dialog to locate a formula in a report.
- Specifies the criteria with which to find the field.
- Root
Searches for the field from the top node.
- Current Node
Searches for the field from the current node.
- Click the Find Next button and the specified field will be selected in the report.
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 DBField component example, open <install_root>\Demo\Reports\SampleComponents\ForDBField.cls
.