Click the Dataset and Query icon .
When working with a sub-dataset, open the dialog by right-clicking the dataset name inside the Outline view, and selecting Dataset and Query....
Right-Click Menu |
|
Use the Dataset and Query dialog to:
| • | Select a data adapter with which to configure the dataset. Usually a data adapter is selected, but you can change it. |
| • | Select a query language for the dataset you're editing. (This can be the main dataset or a sub-dataset that populates a chart or a table.) |
| • | Enter a query. A tool is available for several languages including SQL, XPath and JSON. |
| • | Retrieve the fields from the selected Data Adapter. These can be provided directly by the Data Adapter or by executing the query and reading the response metadata. |
| • | Add, edit, or remove fields and parameters. |
| • | Provide an expression to filter dataset records. |
| • | Preview your data, if supported by the selected data adapter. |
Data Preview Tab |
|
Defining all the fields of a report by hand can be tedious. JasperReports requires all report fields to be named and configured with a proper class type. The Dataset and Query dialog simplifies the process by automatically discovering the available fields provided by a data adapter, without using a query. To execute a query you need to use the proper data adapter: for example to execute an SQL query you must use a JDBC data adapter. The Read Fields button starts the discovery process: the fields found are listed in the Fields tab and added to the report. Click OK to close this window.
Some query languages, like XPath, do not produce a result that resemble a table, but more complex structures that require extra steps to correctly map result data to report fields. An example of this is the multidimensional result coming from MDX results (MDX is the query language used with OLAP and XML/A connections): in this case each field is mapped by specifying an expression stored in the field description. For some languages, such as instance XPath and JSON query, the Query dialog displays a tool that simplifies the creation of both the query and the mapping.
Recommended Comments
There are no comments to display.