Modify an iReport Template

Revision as of 14:51, 17 September 2013 by Noah (talk | contribs) (Fields, Variables, and Parameters)

Overview

Once an iReport template has been created, there are many options for modifying the report template including adding new fields, creating variables, filtering the query results and many other options. This section covers the main customizations performed on iReport templates for use in IMSMANG

Fields, Variables, and Parameters

Adding a Field to an iReport Template

If you need to include a field that was not selected while using the Report Wizard, there are several options for including additional fields. The definition of a field

Option 1

Using the Report Query dialogue, you can select the option to Get Fields from Datasource Provider, which will automatically add all fields from the selected datasource to the report template. You can then remove any unwanted fields from the report

Warning.jpg Make sure that the datasource selected in iReports corresponds to the data source for the report
To add fields from the Report Query dialogue:
  1. Choose the Report Query button
    Report Query Button
    iReport Report Query Button
  2. From the Report Query Window, choose the Datasource Provider tab.
    Report Query Window
    Report Query Window
  3. Select the Get Fields From Datasource button.
    Datasource Fields
    Datasource Fields
  4. All fields will now be displayed. Unnecessary fields can be removed at this time.
  5. Choose Ok to save the fields and return to the iReport Designer.

Option 2

Alternatively, you can create a new report template using the Wizard and add the desired fields to the new report. Fields can then be copied and pasted from the new report to the original report.

  1. Create a new report using the iReport Wizard and the same data source
  2. Select the desired fields and finish the report
  3. Using the Report Inspector, navigate to the desired fields
  4. Right click on the field and select copy.
    Field Copy
    Field Copy
  5. Navigate to the original report with the missing fields
  6. Right-click on the fields tree in Report Inspector and choose paste.
Note.jpg It is not recommended to the use the "Add Field" option from the Report Inspector due to the complexity of adding the correct field attributes and properties.

Adding a Parameter to an iReport Template

It is sometimes necessary to add a parameter to an iReport template. Usually parameters are used for transferring data from a main report to a subreport. Below are the steps to add a parameter to an an iReport Template.

  1. From the Report Inspector, right click on the Parameter tree and choose Add Parameter.
    Add Parameter
  2. In the Properties pane, enter a parameter name (e.g. ItemGUID} and edit any other properties. Normally it is not required to edit anything other than the name.
    Add Parameter

Adding a Variable to an iReport Template

Often it is necessary to add a variable to an iReport template. Variables are used to store calculations and totals in an iReport template. They are often used in the Summary Band portion of a report to store sums of numeric fields (e.g. areaSize) or record counts. There are two main ways to add variables to an iReport template.

=For numeric variables

For variables that are numeric (area sizes, number of devices, etc):

  1. From the Report Inspector, Select the field that you wish to sum or count.
  2. Drag the field to the Summary Band of the iReport Template canvas
  3. A dialogue will pop up, select The result of an aggregation function and choose the calculation type you want to perform.
    Select aggregation function
    Choose the type of calculation
  4. Choose OK
  5. The variable will now appear in the Report Inspector and can be used in the iReport.
    Select aggregation function
    Choose the type of calculation
To add a variable manually

This may be required when adding more complicated variables such as variables designed to perform calculations on one or more fields or when using fields that are not numeric.

  1. From the Report Inspector right click on the Variable tree and choose Add Variable.
    Add Variable
    Add Variable
  2. In the Properties pane,
    Variable Properties Pane
    Variable Properties Pane
    1. Enter a Variable name (e.g. SumAreaSize}
    2. Select the variable class (i.e. the type of variable to be created. Normally this is the same as the type of the field to be used).
    3. Choose the Calculation type, normally Sum or Count
    4. Enter a Variable Expression. Normally this is simply selecting the field to be summed or counted (e.g. $F{areaSize})
    Edit Variable Expression
    Edit Variable Expression
    1. Choose OK
  3. Drag the variable to iReport template as desired.

Report Query Filtering

Filtering results/Query Limitation

the SQL Field

Editing the SQL Field

Sorting and Grouping

Grouping

<p>Grouping allows you to organise the report results using the values of a particular field. Grouping results makes it easier to identify the records which share a common value. Rather than having to visually scan the report results to determine which records have a common value, grouping automatically organises the results for you.

To illustrate, suppose you wanted to create a report to list all land within each location ID. An ungrouped report would simply list all land along with their location ID. Although the location ID is included in the report, it would be difficult, tedious, and time-consuming to scan the entire report to identify those land that have a common location ID.

Figure 7. Land report with no grouping

Figure 7. Land report with no grouping

Grouping report results automatically organises the records using the values on the specified field. Using the example above, the land in the report shown in Figure 8 are organised within the location to which they are associated. Records that do not contain a value for the selected grouping are put into their own group.

 Land grouped by location

Land grouped by location

Adding a Group to an iReport Template

Note.jpg The field on which you would like to group your report results must be included in the report.

To add a group to an existing report:

  1. From the View menu, select Report Groups.
  2. A window displays the groups for the report.
  3. Click the New button.
  4. The Add/modify group window displays.
  5. Enter an identifier for the group. This should be a meaningful name that allows you to easily identify the contents of the group such as the field on which the results are grouped.
  6. Click the File:IRepExpress.png icon.
  7. The Expression editor window displays.
  8. Ensure that the Objects and expressions tab is selected.
  9. Click Fields.
  10. Double-click the name of the field on which you would like to add a grouping.
  11. The Expression editor window shows $F{FieldName} where FieldName is the name of the field that you selected previously.
  12. Click the Apply button.
  13. The Add/modify group window displays the expression in the Group Expression field.
  14. Click the OK button.
  15. The Add/modify group window closes.
Note.jpg You may also enter the expression in the Group Expression field if you know the exact spelling of the field name on which you would like to group the results. The syntax is $F{FieldName}.

Sorting Report Results

It may be helpful to sort the report results using the value in one or more of the fields. Sorting the results makes it easier to review the results and locate any records that you may be searching for. To sort report results:

  1. Create the report.
  2. From the Data menu, select the Report Query option.
  3. The Report query window displays.
  4. Click the Sort options button that is located at the bottom of the Report query window.
  5. The Sorting Options window displays.
  6. Click the Add Field button.
  7. The Sort Field window displays. The Sort by list displays all the fields that you have selected for the report.
  8. From the Sort by list, select the field by which you would like to sort the report results.
Note.jpg When sorting data in reports that contain groups, ensure the “Group by” fields appear first in the sort order.
  1. From the Sort Type list, select either the Ascending or Descending sort order.
  2. Click the OK button.
  3. The selected field displays in the Sorting Options window.
  4. Repeat steps 4-7 for each field on which you would like to sort the results.
  5. After you have completed adding the fields on which you would like to sort the results, click the Close button.
  6. The Sorting Options window closes.
  7. From the Report query window, click the OK button.
  8. The Report query window closes.

You will need to compile and execute the report for the sort options to take effect.

Contents

Working with Images=

Adding an Image to an iReport Template

????