Template¶
The DataFlex Reports library contains one component template that can be used to create a report view component in the DataFlex Studio. With this template, you can build the same kind of component as with the wizard when you select 'Embedded in Report View'. The difference is that you need to do it all 'by hand'. The created report view contains a command bar object with a toolbar, a cDRReport object, and two buttons.
phoReport Property¶
The report view object defines a property named phoReport, which stores the object ID of the cDRReport object. This property is used by the command bar button objects, such as oNextPage. Using this property simplifies changing the name of the cDRReport object without needing to update multiple references.
While you can change the assignment for this property in the code for the cDRReport object, it is neither necessary nor recommended. The code written by the template contains:
Object oReport is a cDRReport
Set Size to 215 397
Set Location to 18 7
Set phoReport to Self
End_Object
oCommandBars Object¶
A means of browsing through pages of the report preview is desirable. One way to achieve this is by adding a CodeJock class-based toolbar inside the report view. The toolbar is, in fact, a command bar, and thus you see an oCommandBars object.
oDRToolbar Object¶
By default, this object contains nine button objects to control the previewed report. All button objects are instantiated from a class that derives from the cDRMenuItem class. The following toolbar buttons are created:
First Page¶
Clicking this button will send PreviewFirstPage to the report object retrieved by the ReportObject function call. The picture displayed is FirstPage.bmp, and it is advised to add this to the embedded images via the project properties.
Previous Page¶
Clicking this button will send PreviewPreviousPage to the report object retrieved by the ReportObject function call. The picture displayed is PreviousPage.bmp, and it is advised to add this to the embedded images via the project properties.
Current Page¶
This 'button' is an edit control with spin functionality that displays the current page of the report preview and allows the operator to enter a different page number. The piPreviewCurrentPage will be set to the entered page number when the operator presses the Enter key or uses the up/down spin buttons. The report object is retrieved via the ReportObject function call.
Next Page¶
Clicking this button will send PreviewNextPage to the report object retrieved by the ReportObject function call. The picture displayed is NextPage.bmp, and it is advised to add this to the embedded images via the project properties.
Last Page¶
Clicking this button will send PreviewLastPage to the report object retrieved by the ReportObject function call. The picture displayed is LastPage.bmp, and it is advised to add this to the embedded images via the project properties.
Refresh Report Data¶
Clicking this button will send RefreshReport to the report object retrieved by the ReportObject function call. The picture displayed is Refresh.ico, and it is advised to add this to the embedded images via the project properties.
Print Report Data¶
Clicking this button will send PrintReport to the report object retrieved by the ReportObject function call. The picture displayed is Print.bmp, and it is advised to add this to the embedded images via the project properties.
Current Zoom Factor¶
This 'button' is an edit control with a dropdown option that allows you to enter a zoom factor for the report freehand or choose from a predefined set of zoom factors. The control will also show the current zoom factor of the previewed report. The report object to be addressed is retrieved via the ReportObject function call. The zoom factor must be between 25% and 500%.
Export Report Data¶
Clicking this button will send ExportReport to a report options dialog, passing the report object retrieved by the ReportObject function call. The report options dialog is specified in the property phoExportOptionsDialog defined for the class of this button. The picture displayed is Export.bmp, and it is advised to add this to the embedded images via the project properties.
oReport Object¶
This is the DataFlex Reports proxy object that allows your DataFlex Reports program to access the report, alter filters, change sorting, etc., and then run the report. The report object by default stores its object ID in the phoReport property of the ReportView object.
Events¶
All events defined for the cDRReport class are supported and can also be found in the events tab-page of the object properties panel in the DataFlex Studio.
The template sets up three events:
The OnPageChanged and OnZoomChanged events communicate with a toolbar 'button' object, and since it is common to configure the report execution, the OnInitializeReport event is added to the object.
Button Objects¶
Finally, the template adds two buttons to the ReportView object. The button named oRunButton sends RunReport to the report object via the object ID in phoReport. The button named oCancelButton attempts to close the component.
To allow the user to easily execute the messages that the buttons send, two On_Key statements are added; these send the KeyAction messages to the appropriate button. The key combinations are Alt+C and Alt+R.
Other Key Mappings¶
The template also defines On_Key statements for browsing to the first (Ctrl+Home), next (PageDown), previous (PageUp), and last page (Ctrl+End) of the report.