Binding a Parameter to a DBField
Logi JReport provides a mechanism which links each field value of a "display column" with the exact value of a "bind column". When you select the field value from the "display column", the field value of the "bind column" is sent to the query to filter the query result. Both columns can come from any data source in a catalog, and Logi JReport always retrieves just distinct values from the data source for the columns. So even though the value selection might be Countries from Customers, only countries with current customers will be displayed.
For example, if you specified customer ID to query data, but you would like to show customer name not customer ID for the parameter values which display at runtime, you can do so by selecting a different column for the display column than for the bind column. By default the bind column and display column are identical.
- Open the catalog file SampleReports.cat in
- In the Catalog Manager, expand the data source where to create the parameter.
- Right-click the Parameters node and select New Parameter on the shortcut menu.
- In the New Parameter dialog, enter BindColumn in the Name field, select Bind with Single Column from the Value Setting drop-down list, select Tables and Views from the Source drop-down list, then select Customer ID from the Bind Column drop-down list, and choose Customer Name from the Display Column drop-down list. Select OK.
Note: Selecting a display column different from the bind column will establish a link between the two columns (DBFields). When you select the field value from the display column, the corresponding field value of the bind column is actually assigned to the parameter.
- In the same data source, create a query CustomersInfo on the table Customers. Select all the fields contained in the table.
- Create a page report with a standard banded object in it based on the query, and have the fields Customer ID, Customer Name, City and Phone displayed in the report.
- In the Data panel, right-click the node that represents the query, and then select Edit Query from the shortcut menu.
- In the Query Editor, select Menu > Query > Filter.
- In the Search Condition dialog, add a condition for the query as follows (for details, see Filtering with the Filter Format):
- Select OK to apply the changes to the query.
- Select the View tab to view the report. All the customer na
- mes will be listed in the Enter Parameter Values dialog. You can select a value from the list to query data with the customer ID instead of customer name.