This report bean example (bean.srt in the examples/docExamples/script directory) is based on the table example. It changes two parts of the report into report beans:
Note: Set your Registry location to examples/docExamples/script. See Registry Configuration in Report Designer for instructions.
Figure 3. Report Bean Example
Making a report bean from the report header does not require any redesign. Simply copy and paste the appropriate elements into a report bean and define the appropriate properties.
The script on the date field remains the same:
var now = new Date(); switch(now.getMonth()) { case 0: case 1: case 2: text = "1sr Qtr"; break; case 3: case 4: case 5: text = "2nd Qtr"; break; case 6: case 7: case 8: text = "3rd Qtr"; break; case 9: case 10: case 11: text = "4th Qtr"; break; } text = text + ", " + formatDate(now, 'yyyy');
Since the script uses the property of the text element it is attached to, the references are automatically resolved to the current element. To use the bean, simple replace the elements in the report with the bean.
The elements for displaying the two totals are almost identical. We will replace these elements with a report bean following a similar procedure:
var total1 = 0, total2 = 0; for(var i = 1; i < table.length; i++) { var price = table[i]['Total']; if(price > 1000) { for(var c = 0; c < table[i].length; c++) { cellBackground[i][c] = 0xBBFFBB; } total1 += price; } else { total2 += price; } } totalOver.value = formatNumber(total1, '$#,###.00'); totalBelow.value = formatNumber(total2, '$#,###.00');
A report bean can be a complete component with presentation elements, properties and dynamic behaviors. We will provide additional examples of how to use report beans to encapsulate complete components.
Copyright © 2024, InetSoft Technology Corp.