The final viewer to be covered in this chapter is the Grid viewer. The Grid viewer (shown in Figure 32.4) differs more from the other viewers in that it does not render the report's presentation onscreen. Instead it looks at the dataset associated with the report (that is, the query result after the report engine has done its magic) and displays that data in a tabular fashion. This opens up some very interesting scenarios if you use your imagination.
NOTE
You can override the style of the grid table by defining a stylesheet that maps to the styles used by the grid object. Consult the documentation for more information on this.
Listing 32.9 shows a report being displayed using the Grid viewer.
//To create a Java grid viewer you need to instantiate a GridViewer object. //To create a GridViewer object: GridViewer viewer = new GridViewer(); //Set the viewer's report source by calling its setReportSource method viewer.setReportSource(reportSource); //After you have created and initialized a Java grid viewer object, you call //its processHttpRequest method to display the results in the Web page viewer.processHttpRequest(request, response, getServletContext(), null); |
All viewers including the Grid viewer share a number of toolbar elements. These properties can be programmatically toggled and are displayed in Table 32.3. All the viewer properties must be set before calling the ProcessHTTPRequest method that will display the selected report. For example, to ensure the Crystal logo is displayed when the involved report is viewed, the code line
Viewer.HasLogo(true);
needs to be included in the code before the processHTTPRequest method is called.
18.119.103.204