Skip to content

Visual Report Writer and The Web (XIII)

In this thirteenth blog about Visual Report Writer and the Web, I want to tell you how you can create an interactive report. A demo of such a report can be found at the Live Demo website (European Server, USA server). If this is the first blog you are reading, I encourage you to check out the twelve other blogs: 1. The Solution 2. Invoices Report 3. The Cleanup 4. The CustomerList 5. The OrderList 6. The Credit and Balances Overview 7. Inventory Stock Levels 8. Sick Leave 9. FileList (RDS) 10. Four Wine Data Based Reports 11. Top 10 Salespersons 12. Report Related Topics

Meanwhile, we have released the Beta II version of Visual Report Writer 3.0 and the 2.1+ Library only setup. The latter is necessary for web reporting using the 17.1 DataFlex Web Framework, making it easy to replicate the demo website when using Visual Report Writer 2.1. Using 3.0 Beta does not require the 2.1+ library.

The Report

The report in the live demo site that demonstrates interaction with the web framework application is called Sick Leave Overview. Run the report and observe that the employee name is underlined, and the mouse cursor changes when hovering over it, indicating a hyperlink. However, this is not a standard hyperlink; clicking it opens a modal dialog in the web framework application. The executed report contains an attribute that allows the Visual Report Writer engine to generate additional HTML attributes in the data element. This attribute is called Hyperlink ID and can be found and modified in the field properties dialog. This feature is available only in Visual Report Writer 3.x.

If a value greater than 0 (zero) is entered in this input field, the Visual Report Writer print engine adds the following HTML attributes to the div element for this field:

class="RW_Click"
data-rwtype="1"
tabindex="0"

The entered ID value is used as the value of an HTML attribute named data-rwtype. This value serves as a way to determine the action to take when the user clicks on the value displayed inside the element. The class allows the viewer to style the cursor appearance and underline the data, while the tabindex makes the data selectable.

The HTML Report Viewer

At the report integration level, the results of the report are streamed into a large string and displayed in a special previewer component designed for integrating Visual Report Writer with the DataFlex Web Application Framework. The viewer responds to mouse click events and checks if the click occurred on an element containing the data-rwtype attribute. If so, an event named OnClickActionLink is triggered. You need to set the property pbServerOnClickActionLink to true to receive the event at the DataFlex web server interface. The event provides the data of the element and the value of data-rwtype as eDataType.

It is then up to you to program some action. The following code illustrates what is done in the demo application:

Object oViewer is a cWebVrwReportViewer
    Set phoReport to oReport
    Set pbServerOnClickActionLink to True

    Procedure OnClickActionLink String sData Integer eDataType
        Send ShowEmployee of oSQLEmployeeModalDialog Self sData
    End_Procedure
End_Object

Since there is only one hyperlink ID in the report, the above code does not utilize the value of the hyperlink ID, but it can be modified to perform a different action.

The ShowEmployee method takes the sData value and locates a row in the employee table. If found, it will be displayed in the modal dialog. The modal dialog can show the employee information and, based on the logged-in user, also allows editing of the employee data.

Procedure OnShow
    Integer iUserRights

    Forward Send OnShow

    Send Clear of oSQLEmployee_DD
    WebGet psEmployeeName to SQLEmployee.LastName
    Send Find of oSQLEmployee_DD Ge 7

    Get piUserRights of ghoWebSessionManager to iUserRights
    WebSet pbEnabled of oSaveAndCloseButton to (iUserRights <= C_DATAEDITRIGHTS)
    Broadcast Send ChangeEnabled of oMainPanel (iUserRights <= C_DATAEDITRIGHTS)
End_Procedure

Saving is restricted if the logged-in user does not have the appropriate rights.

Procedure Request_Save
    Integer iUserRights

    Get piUserRights of ghoWebSessionManager to iUserRights
    If (iUserRights <= C_DATAEDITRIGHTS) Begin
        Forward Send Request_Save
    End
End_Procedure

This concludes the latest blog about Visual Report Writer Web integration at this time. I hope it encourages you to start using Visual Report Writer in conjunction with the DataFlex Web Application Framework.