Visual Report Writer and The Web (XIII)
by
, 13-Jul-2013 at 12:02 AM (19973 Views)
In this thirtheenth blog about Visual Report Writer and the Web I want to tell you how you can make a report that is interactive. A demo of a report that does this can be found at the Live Demo website (European Server, USA server). If this is the first blog you read I encourage you to read 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) and 12: Report Related Topics). Meanwhile we have been able to release the Beta II version of Visual Report Writer 3.0 and the 2.1+ Library only setup. The latter one is needed to make the web reporting using the 17.1 DataFlex Web Framework easy and look like at the demo website when using Visual Report Writer 2.1. Using 3.0 Beta does not need the 2.1+ library.
The Report
The report in the live demo site that shows interaction with the web framework application is called Sick Leave Overview. Run the report and see that the employee name is underlined and the mouse cursor changes when sliding over. A hyperlink thus. But not a normal hyperlink as click opens a modal dialog in the web framework application. The report that gets executed contains an attribute which let the Visual Report Writer engine generate extra HTML attributes in the data element. The attribute is called "Hyperlink ID" and can be found and changed in the field properties dialog. This is Visual Report Writer 3.x only.
If a value larger 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.
The entered id value is added as the value of an HTML attribute named data-rwtype. The value that can be entered should be seen as a way to determine what to do if the user clicks on the value printed inside the element. With the class the viewer can style the cursor look and underline of the data. The tabindex makes the data selectable.
- class="RW_Click"
- data-rwtype="1"
- tabindex="0"
The HTML Report Viewer
At report integration level the results of the report are streamed into a large string and shown in a special previewer component written for integration of Visual Report Writer with the DataFlex Web Application Framework. The viewer responds on a mouse click event and finds out if the click was given on an element containing the data-rwtype attribute. If so an event named OnClickActionLink will be fired. You need to set the property pbServerOnClickActionLink to true to actually receive the event at the DataFlex web server interface. The event gets the data of the element and the value of data-rwtype as eDataType.
Then it is up to you to program some action. The following code shows what is done in the demo application.
Since there is only one hyperlink ID in the report the above code does not do anything with the value of the hyperlink ID but it can be changed to perform a different action.Code: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
The ShowEmployee method takes the sData value and finds a row in the employee table. If found it will be displayed in the modal dialog. The modal dialog itself can show the employee information but based on the logged in user also allows editing of the employee data.
Saving is blocked if the logged in user does not have the appropriate rights.Code: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
This concludes the last blog about Visual Report Writer Web integration at this moment. I hope it encourages you to get going with Visual Report Writer in combination with the DataFlex Web Application Framework.Code:Procedure Request_Save Integer iUserRights Get piUserRights of ghoWebSessionManager to iUserRights If (iUserRights <= C_DATAEDITRIGHTS) Begin Forward Send Request_Save End End_Procedure