Product(s): | Promis.e, Bentley Substation | ||
Version(s): | through 08.11.13.140 | ||
Environment: | N/A | ||
Area: | Template Management | ||
Subarea: | Report Template Designer |
Data can be read from the project database and displayed on reports by simply dragging a data field onto the report template in [[Report Template Designer]]. It is possible to manipulate data from the database before it is displayed on the report by using scripts in Report Template Designer. Such BeforePrint scripts can "overwrite" the contents of the table cell or label they are applied to, even if a data field is bound to the cell or label. The scripts can perform other functions as well, such as tallying, without manipulating how the data in the cell appears. This document describes how to use BeforePrint scripts as a reference for other articles. See the articles listed in the See Also section for specific BeforePrint script examples.
The script language specified for the template and the language used in the scripts must be the same. The language specified for the template can be found by looking in the Script Language field in the Property Grid immediately after opening the template or by right-clicking the root node in the Report Explorer tree and selecting Properties:
Open a project page using [[Project Manager]].
Open [[Report Template Designer]].
Select File > Open and open the report template.
In the Designer view (Designer tab along the bottom of the Report Template Designer), find the table cell or Label that the script is to affect.
Right-click this cell or label and select Properties.
On the resulting Property Grid view, expand the Scripts row. The Scripts row is in the Behavior category.
Click the down arrow button that appears in that row.
Paste or compose the intended script within the curly brackets { } of the new function. Be sure not to delete or overwrite the function declaration line (private void...{ ) and closing curly bracket.
private void xrTableCell20_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
// paste script here
}
Preview the report by clicking the Preview tab.
If the results are acceptable, use File > Save to save the template or File > Save As to save it as a new template.
Close the Report Template Designer.
To modify an existing script, click the Scripts tab at the bottom of Report Template Designer and find the script.
Open a project page using [[Project Manager]].
Open [[Report Template Designer]].
Select File > Open and open the report template.
In the Designer view (Designer tab along the bottom of the Report Template Designer), find the table cell or Label that the script is to affect. Click this cell.
With the cell selected, click the small > button that is revealed above the cell.
On the resulting Table Cell Tasks dialog, clear the Text field and ensure the Data Binding field is set to "None".
Click away from the Table Cell Tasks dialog to dismiss it. The cell selected in step 4 should now have no text in it.
Right-click this cell or label and select Properties.
On the resulting Property Grid view, expand the Scripts row.
Click on the OnBeforePrint row.
Click the [...] button that appears in that row. This will open a Script Editor dialog showing the current script for the OnBeforePrint event.
Paste, compose, or modify the intended script within the curly brackets { } of the function. Be sure not to delete or overwrite the function declaration line (private void...{ ) and closing curly bracket.
private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
// paste script here
}
Preview the report by clicking the Preview tab.
If the results are acceptable, use File > Save to save the template or File > Save As to save it as a new template.
Close the Report Template Designer.
To modify a script, repeat steps 4 through 7.
To remove a script, repeat steps 4 through 7 and click the Default Script button on the Script Editor dialog.
If the script seems unable to populate the cell or label, try unbinding the Field:
With the cell selected, click the small > button that is revealed above the cell.
On the resulting Table Cell Tasks dialog, clear the Text field and ensure the Data Binding field is set to "None".
Click away from the Table Cell Tasks dialog to dismiss it. The cell selected in step 4 should now have no text in it.
[[Add leading zeros to numbers on reports]]
[[Concatenating fields on report templates]]
[[Quantified BOM report with device IDs on a single line]]
[[Removing Terminal CP Text from Wire Lists]]
[[Remove caret characters from reports]]
[[Rounding up quantities on BOM reports]]
Scripting Overview - DevExpress
Original Author: | Matt_P |