Working with Text Fields Activity

 

 

 

Step

Action

1. 

Activity End Result

At the end of this activity your Department Report displays a title, three headers, and department names and ID numbers, as displayed above.

 

To achieve this you:

- Add Text Fields to the report template, including title and column headers

- Configure Text Field properties

- Display data returned by a query in the report

2. 

Open the Department Report you created previously.

3. 

Begin by adding a title to the report.

 

Drag a Text Field element from the Palette into the Title band.

4. 

Note: The text field appears in the Title band.

5. 

If you don't see it, open the Formatting Tools panel from the Window menu.

 

Next, format the text field in the Title band.

 

Click the text field in the Title band to select it.

6. 

Scroll to the bottom of the Formatting Tools panel and click the Adapt to parent width button to stretch the text field as wide as its band.

7. 

Note: The text field stretches to the same width as its band.

8. 

Configure the title text in the Properties panel as follows:

 

- Text Field Expression: “Departments Summary” (notice the double quotation marks)

- Size: 20

- Height: 26

- Horizontal Alignment: Center

 

Click the Text Field Expression edit button to configure the title.

9. 

Note: The Expression Editor appears.

10. 

Enter ""Departments Summary"" into the Expression field.

11. 

IMPORTANT

Include double quotation marks around simple text entered into a Text Field expression. A string expression lacking double quotation marks results in an error when the report is previewed. The quotation marks are not visible during preview.

12. 

Click the OK button to save the expression and close the editor.

13. 

Note: The title expression now appears in the report.

14. 

Specify a larger font size for the title.

 

Click the Size drop-down button to activate the menu.

15. 

Click the 20 list item.

16. 

Note: The title expression no longer displays because the larger font size made the expression taller than the text field.

17. 

Increase the text field height to make the title expression visible.

 

Enter "26" into the Height field.

18. 

Press [Enter] to commit the change.

19. 

Note: The text field is taller and the expression is visible again.

20. 

Next, center the title.

 

Click the Horizontal Alignment drop-down button to activate the menu.

21. 

Click the Center list item.

22. 

Note: The title expression is now centered in the band.

23. 

Note: Next, give the Column Header band a background color on which report data is displayed. Background color is a property of the Frame element.

24. 

Drag a Frame element from the Palette into the Column Header band.

25. 

Now, resize the frame to fill the band.

 

Click the Frame to select it.

26. 

Note: The frame information is displayed in the Report Inspector under the Column Header node as four comma-separated numbers. The first two represent the number of pixels the top-left corner of the frame is to the right of and below the top-left corner of the band. The last two numbers represent the frame's initial length and height in pixels.

27. 

In the Formatting Tools panel, click the Adapt to parent button to fully expand the frame.

28. 

Note: The frame stretches to match the band's length and height.

29. 

Now specify the background color.

 

In the Properties panel, click the Backcolor edit button to open the color palette.

30. 

Note: The Backcolor palette appears.

31. 

Click the gray cell in the middle of the left-most column.

32. 

Click the OK button to apply the color and close the palette.

33. 

In the Properties panel, click the Opaque option to make the background color visible.

34. 

Note: The gray background color now fills the frame.

35. 

Next, add data to the report.

 

Expand the Fields node in the Report Inspector.

36. 

Click the department_department_description tree item and drag it into the Detail band.

37. 

Note: A static text (label) column header was automatically inserted above in the Column Header band.

38. 

Drag the department_id field into the Detail band and drop it alongside the department_description field.

39. 

Note: The department_id field appears in the Detail band, and a static text field is included above it.

40. 

Next, align the fields with the top margin of the Detail band. 

 

Control-click to select both text fields in the Detail band.

41. 

In the Formatting Tools panel, click the Align To Top Margin button.

42. 

Note: Both text fields now align with the band's top margin.

43. 

Next, align the fields side by side.

 

Drag the department_id text field to its left so the two field end borders touch.

44. 

Next, edit both labels' text.

 

Double-click the department_department_description label.

45. 

Enter "Department" into the field.

46. 

Press [Enter] to commit the change.

47. 

Double-click the department_id label to edit its text.

48. 

Enter "Employee Count" into the department_id field.

49. 

Press [Enter] to commit the change.

50. 

In a later activity, the report is configured to display each department's name, number of employees, and total salary. The Column Header band already has two of the three column header labels it needs. Add a third label for total salary.

 

Drag a Static Text element from the Palette into the Column Header band to the right of the Employee Count label.

51. 

Double-click the new Static Text field to edit it.

52. 

Enter "Total Salary" into the Static Text field.

53. 

Press [Enter] to commit the change.

54. 

Note: The label is updated.

 

55. 

Align all three Column Header text labels at the top of the band.

56. 

Next, specify the column header text color.

 

Control-click all three Column Header text labels to select them.

57. 

Note: With all three fields selected, set their Forecolor property value.

58. 

In the Properties panel, click the Forecolor edit button.

59. 

Click the White color cell at the upper-left corner of the color palette.

60. 

Click the OK button to close the palette.

61. 

Note: The text of all three labels is white.

62. 

Preview the report to see how it looks.

 

Click the Preview button.

63. 

Note: The report appears in the iReport Preview window and displays a title, three white column headers, color formatting, and data. The department_department_description field provides the department names, and the department_id field provides the department ID numbers.

 

Over the next several activities, data different from what you currently see appears under the three white column headers, and information and formatting is applied to provide a professional look to the report.

64. 

Congratulations!

 

You created a report with a title, column headers, custom formatting, and data.

 

View the Online Learning Portal here (http://www.jaspersoft.com/online-learning-portal).

End of Procedure.