Previous TopicNext Topic


How to use BIRT Report Designer to enter a JavaScript event handler

  1. In Outline, select the report element, data source, or data set for which you want to write an event handler.
  2. Choose the Script tab.
  3. Choose an event handler from the drop-down list of methods.
  4. Enter the event handler code in the script editor.

Figure 23-6 demonstrates entering a line of code in the onPrepare( ) method of a Table element.

Figure 23-6 Code entry for the onPrepare( ) method
  1. Select the label whose color you want to change by navigating the Outline view and selecting the appropriate report item, as shown in Figure 23-7.
  2. Figure 23-7 Selecting a report item to modify
  3. Select onPrepare from the drop-down list in the script editor, as shown in Figure 23-8.
  4. Figure 23-8 Selecting onPrepare( )
  5. Enter the word this, followed by a period in the onPrepare script editor, as shown in Figure 23-9.
  6. Figure 23-9 Using the this object
  7. Select the getStyle( ) method from the scrollable list of properties and functions.
  8. The onPrepare script window appears as shown in Figure 23-10.

    Figure 23-10 The onPrepare script window
  9. Move the cursor to the end of the line in the onPrepare script window and type a period.
  10. The scrollable list of properties and functions of the Style element appears, as shown in Figure 23-11.

    Figure 23-11 Properties and functions of the Style element
  11. Select backgroundColor from the list of Style properties and functions.
  12. The property name backgroundColor is appended to the line of JavaScript, as shown in Figure 23-12.

    Figure 23-12 Select the backgroundColor property
  13. Complete the line of JavaScript in the onPrepare script window by appending ="yellow", as shown in Figure 23-13.
  14. Figure 23-13 Changing the color of an element
  15. Choose the Preview tab to see the effect of the onPrepare event handler script.
  16. The label appears in the report with a yellow background, as shown in
    Figure 23-14.

    Figure 23-14 Preview of the color change

(c) Copyright Actuate Corporation 2006

Previous TopicNext Topic